Actually in the previous semester I have also made some Tkinter application which is the project given by teacher to us. So I go to some tutorials website of Python and find three methods of placing the widgets on the output screen. The three methods are

 1. Pack()
 2. Grid()
 3. Place() #the best method over Pack() and Grid()

Place() method take the coordinates in the form of the x and y. See this link for more clarification https://www.tutorialspoint.com/python/python_gui_programming.htm

https://www.tutorialspoint.com/python/tk_place.htm

See the bottom of the Page of the given link.The Place() method is defined with its proper arguments. I will prefer the Place() method over Pack() and Grid() because it works like CSS as we use in html, because it take the value of (width,height) and place your widget according to wherever you want.

If you find your answer a thumbs up will be appreciated.

Answer from Akshay Kathpal on Stack Overflow
🌐
ActiveState
activestate.com › home › resources › quick read › how to position buttons in tkinter
How to Position Buttons in Tkinter - with Grid, Place or Pack - ActiveState
January 24, 2024 - The pack manager organizes widgets in horizontal and vertical boxes that are limited to left, right, top, bottom positions offset from each other. The grid manager locates widgets in a two dimensional grid using row and column relative coordinates.
🌐
ActiveState
activestate.com › home › resources › quick read › how to position buttons in tkinter with pack
How To Position Buttons In Tkinter With Pack (Demo and Codes) - ActiveState
January 24, 2024 - In this example, pack() uses the side option to position buttons in the left, right, top and bottom sections of a frame: This code will draw four buttons, and the placement of each button is specified by left, top, right, and bottom sections ...
Discussions

python - How do I position buttons in Tkinter? - Stack Overflow
I have a program here that has two buttons in it. I am trying to change their position to be a space between them as currently they are directly below each other. What should I do to change the pos... More on stackoverflow.com
🌐 stackoverflow.com
Button Placement Using '.grid' via tkinter
Hello, I am getting familiar with the tkinter package/library. In my test program, I would like to test the three different placement options using either pack, place, or grid. Using either the place or the pack options seem to work just fine. However, when I attempt to use the grid placement ... More on discuss.python.org
🌐 discuss.python.org
7
0
October 23, 2023
Positioning buttons and entry in python tkinter - Stack Overflow
To begin with, I'm new to this but I've been experimenting with different things. I set my canvas size to 500 by 500 but Its going above that due to the buttons and entry positions (I think). How ... More on stackoverflow.com
🌐 stackoverflow.com
tkinter - Setting the position on a button in Python? - Stack Overflow
How do you set the row and column of the button? I tried to add row = 0, column = 0, but that would not work. ... Causing a widget to appear requires that you position it using with what Tkinter calls "geometry managers". The three managers are grid, pack and place. More on stackoverflow.com
🌐 stackoverflow.com
🌐
ActiveState
activestate.com › home › resources › quick read › how to position buttons in tkinter with place
How To Position Buttons In Tkinter With Place (Demo and Codes) - ActiveState
January 24, 2024 - When working with Tkinter button positioning using the pack() function, you will likely want to use padding options to better position the button (or other widget) in relation to the left, right, top, bottom sides of the widget.
🌐
YouTube
youtube.com › activestate
How to position buttons in Tkinter with Pack - YouTube
How to Position Buttons With PACK Pack() has three options you can use: side, fill, expand. The side option aligns buttons horizontally. The fill option alig...
Published   September 9, 2020
Views   172
🌐
Python.org
discuss.python.org › python help
Button Placement Using '.grid' via tkinter - Python Help - Discussions on Python.org
October 23, 2023 - Hello, I am getting familiar with the tkinter package/library. In my test program, I would like to test the three different placement options using either pack, place, or grid. Using either the place or the pack options seem to work just fine. However, when I attempt to use the grid placement ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-place-a-button-at-any-position-in-tkinter
How to place a button at any position in Tkinter? - GeeksforGeeks
July 23, 2025 - # Importing tkinter module from ... coordinate (100, 20) btn.place(x=100, y=20) root.mainloop() ... This method is used to place a button at a relative position....
Find elsewhere
🌐
Python Assets
pythonassets.com › posts › placing-widgets-in-tk-tkinter
Placing Widgets in Tk (tkinter) | Python Assets
August 5, 2021 - In this example, we create a textbox and a button, and place them in the window via the pack() function. Since we passed no arguments, Tk will by default place the widgets one above the other, as shown in the following image.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-move-a-tkinter-button
How to move a Tkinter button? - GeeksforGeeks
July 23, 2025 - # Importing tkinter module from tkinter import * # Creating a tkinter window root = Tk() # Initialize tkinter window with dimensions 300 x 250 root.geometry('300x250') # Creating a Button btn = Button(root, text = 'Click me !', command = root.destroy) # Set a relative position of button btn.pack(side=RIGHT, padx=15, pady=20) root.mainloop()
🌐
Stack Overflow
stackoverflow.com › questions › 62009047 › positioning-buttons-and-entry-in-python-tkinter
Positioning buttons and entry in python tkinter - Stack Overflow
from tkinter import * root = Tk() root.resizable(width=False, height=False) w = Canvas(root, width=500, height=500) w.pack() textInput = Entry(w, width=50, borderwidth=2) # w, instead of root textInput.pack() def myClick(): myLabel = Label(root, text=textInput.get()) myLabel.pack() def shutDown(): exitProgram = exit() exitProgram.pack() myButton = Button(w, text="Start", command=myClick) # w, instead of root myButton.pack(side=LEFT, padx=20, pady=25) myButton2 = Button(w, text="Stop", command=shutDown) # w, instead of root myButton2.pack(side=RIGHT, padx=20, pady=25) root.mainloop()
Top answer
1 of 3
51

Causing a widget to appear requires that you position it using with what Tkinter calls "geometry managers". The three managers are grid, pack and place. Each has strengths and weaknesses. These three managers are implemented as methods on all widgets.

grid, as its name implies, is perfect for laying widgets in a grid. You can specify rows and columns, row and column spans, padding, etc.

Example:

b = Button(...)
b.grid(row=2, column=3, columnspan=2)

pack uses a box metaphor, letting you "pack" widgets along one of the sides of a container. pack is extremely good at all-vertical or all-horizontal layouts. Toolbars, for example, where widgets are aligned in a horizontal line, are a good place to use pack.

Example:

b = Button(...)
b.pack(side="top", fill='both', expand=True, padx=4, pady=4)`

place is the least used geometry manager. With place you specify the exact x/y location and exact width/height for a widget. It has some nice features such as being able to use either absolute or relative coordinates (for example: you can place a widget at 10,10, or at 50% of the widgets width or height).

Unlike grid and pack, using place does not cause the parent widget to expand or collapse to fit all of the widgets that have been placed inside.

Example:

b = Button(...)
b.place(relx=.5, rely=.5, anchor="c")

With those three geometry managers you can do just about any type of layout you can imagine.

2 of 3
16

astynax is right. To follow the example you gave:

MyButton1 = Button(master, text="BUTTON1", width=10, command=callback)
MyButton1.grid(row=0, column=0)

MyButton2 = Button(master, text="BUTTON2", width=10, command=callback)
MyButton2.grid(row=1, column=0)

MyButton3 = Button(master, text="BUTTON3", width=10, command=callback)
MyButton3.grid(row=2, column=0)

Should create 3 row of buttons. Using grid is a lot better than using pack. However, if you use grid on one button and pack on another it will not work and you will get an error.

🌐
TutorialsPoint
tutorialspoint.com › how-do-i-position-the-buttons-on-a-tkinter-window
How do I position the buttons on a Tkinter window?
# Import the Tkinter library from tkinter import * from tkinter import ttk # Create an instance of Tkinter frame win = Tk() # Define the geometry win.geometry("750x350") # Create Buttons in the frame button = ttk.Button(win, text="Button-1") button.place(x=325, y=125) button = ttk.Button(win, text="Button-2") button.place(x=325, y=175) button = ttk.Button(win, text="Button-3") button.place(x=325, y=225) #Create a Label Label(win, text="Position the Buttons", font='Consolas 15').pack() win.mainloop()
Top answer
1 of 2
1

So I would like the "next set" and "exit" buttons to switch spots.

The packer works by placing widgets along one of the sides of the unallocated space in the master widget. Order matters, since each widget causes the unallocated space to change. For example, if you want a widget on the far right side of a frame, you should pack it on the right before you pack any other widgets.

In your case, the solution is as simple as changing the order in which you call pack.

tk.Button(fram, text="  Exit  ", command=self.destroy, fg = "grey").pack(side=tk.RIGHT)
tk.Button(fram, text="            Next set              ", command=self._load_dataset).pack(side=tk.RIGHT)

I was also wondering if it was possible to show the exit button on the bottom right of the screen.

Yes, it's possible. The simplest solution is to divide your window into three areas: a top set of buttons, a buttom set of buttons, and the image area.

For example, the following code creates three frames for these three areas, and uses pack to arrange them. Once you do these, it becomes trivial to add buttons to the top and bottom frames in whatever order you want.

top_frame = tk.Frame(self)
bottom_frame = tk.Frame(self)
image_frame = tk.Frame(self)

top_frame.pack(side="top", fill="x")
bottom_frame.pack(side="bottom", fill="x")
image_frame.pack(side="top", fill="both", expand=True)

exit_button = tk.Button(bottom_frame, text="Exit", ...)
exit_button.pack(side="right")

previous_button = tk.Button(top_frame, text="Previous Image", ...)
next_button = tk.Button(top_frame, text="Next Image", ...)
next_set_button = tk.Button(top_frame, text="Next Set", ...)

previous_button.pack(side="left")
next_button.pack(side="left")
next_set_button.pack(side="right")

Another way to do this is to make all of the buttons a child of self which makes it easy to define them all in the same block of code, and use the in_ parameter to specify where they go.

exit_button = tk.Button(self, text="Exit", ...)
previous_button = tk.Button(self, text="Previous Image", ...)
next_button = tk.Button(self, text="Next Image", ...)
next_set_button = tk.Button(self, text="Next Set", ...)

exit_button.pack(in_=bottom_frame, side="right")
previous_button.pack(in_=top_frame, side="left")
next_button.pack(in_=top_frame, side="left")
next_set_button.pack(in_=top_frame, side="right")

For the definitive description of how the packer works, see Packer Algorithm in the official tk documentation.

2 of 2
0

An alternative to pack is to use the button's grid attributes to place them in the frame.

I have used separate frames for placing buttons in my app:

frame_buttons = ttk.Frame(tab_details)
frame_buttons.grid(column = 0, row = 3, sticky = tk.EW)
frame_buttons.columnconfigure(0, weight = 1)
frame_buttons.columnconfigure(1, weight = 1)
button_process = ttk.Button(frame_buttons, text = 'Process', command = text_to_xml)
button_process.grid(column = 0, row = 0) # in the centre of the left column
button_clear = ttk.Button(frame_buttons,text = 'Clear', command = clear_entries)
button_clear.grid(column = 1, row = 0) # in the centre of the right column

The grid is described here in the TkDocs site: TkDocs

🌐
TutorialsPoint
tutorialspoint.com › setting-the-position-on-a-button-in-tkinter-python
Setting the position on a button in Tkinter Python?
April 22, 2021 - Try the following example by moving cursor on different buttons − · from tkinter import * top = Tk() L1 = Label(top, text="Physics") L1.place(x=10,y=10) E1 = Entry(top, bd =5) E1.place(x=60,y=10) L2=Label(top,text="Maths") L2.place(x=10,y=50) E2=Entry(top,bd=5) E2.place(x=60,y=50) L3=Label(top,text="Total") L3.place(x=10,y=150) E3=Entry(top,bd=5) E3.place(x=60,y=150) B = Button(top, text ="Add") B.place(x=100, y=100) top.geometry("250x250+10+10") top.mainloop()
🌐
Tutorialspoint
tutorialspoint.com › python › tk_pack.htm
Tkinter pack() Method
side − Determines which side of the parent widget packs against: TOP (default), BOTTOM, LEFT, or RIGHT. Try the following example by moving cursor on different buttons − · from tkinter import * root = Tk() frame = Frame(root) frame.pack() ...
🌐
ActiveState
activestate.com › home › resources › quick read › how to position widgets in tkinter
How to Position Widgets in Tkinter - with Grid, Place or Pack - ActiveState
January 24, 2024 - The widget’s position is changed. button1.pack(side = BOTTOM, padx=<x_coordinate, pady=<y_coordinate>) root.mainloop() Now that you know how to add widgets using Python’s Tkinter, let’s move on to other things you can do with Tkinter:
🌐
Python GUIs
pythonguis.com › faq › when to use pack, place or grid in tkinter
Tkinter Pack vs Grid vs Place — Which Layout Manager Should You Use?
September 18, 2019 - Use pack for quick prototypes or simple interfaces. Place gives you the most control with exact pixel positioning, but requires more effort and planning. Use place when you need precise absolute or relative positioning. Remember: never mix different layout managers within the same parent container -- Tkinter cannot resolve conflicts between pack, grid, and place when used together in a single frame or window.
🌐
Tutorialspoint
tutorialspoint.com › python › tk_place.htm
Tkinter place() Method
Try the following example by moving cursor on different buttons − · from tkinter import * top = Tk() L1 = Label(top, text="Physics") L1.place(x=10,y=10) E1 = Entry(top, bd =5) E1.place(x=60,y=10) L2=Label(top,text="Maths") L2.place(x=10,y=50) E2=Entry(top,bd=5) E2.place(x=60,y=50) L3=Label(top,text="Total") L3.place(x=10,y=150) E3=Entry(top,bd=5) E3.place(x=60,y=150) B = Button(top, text ="Add") B.place(x=100, y=100) top.geometry("250x250+10+10") top.mainloop()
🌐
Beautiful Soup
tedboy.github.io › python_stdlib › generated › generated › Tkinter.Button.pack.html
Tkinter.Button.pack — Python Standard Library
Tkinter.Button.pack · View page source · Button.pack(cnf={}, **kw)¶ · Pack a widget in the parent widget. Use as options: after=widget - pack it after you have packed widget anchor=NSEW (or subset) - position widget according to · given direction ·