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 Overflowpython - How do I position buttons in Tkinter? - Stack Overflow
tkinter - Setting the position on a button in Python? - Stack Overflow
Positioning buttons and entry in python tkinter - Stack Overflow
How do I change the position of a button using Tkinter?
Videos
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.
Mine goes like this:
object1 = Tk()
actionBtn = Button(object1, text="Enter", width=15, height=2, command=quit).place(x=0, y=0)
#.place() is the best thing to use, x and y determine the location in terms of geometry.
you can even add an image with .png extension and goes like this:
buttonEnter = PhotoImage(file="buttonEnter.png") #image file must be inserted
buttonEnter1 = Button(object1, image=buttonEnter, width=20, height=4).place(x=0, y=0)
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.
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.
So I am trying to change the position of a button in Tkinter
This is my full code:
from tkinter import *
window = Tk()
window.title("Nyeeeeeee")
window.geometry('500x500')
B = Button(text ="7", bg="#0099ff")
B.config(height =4, width =11 )
B.pack()
window.mainloop()