How to move a Tkinter button?

12,136

Solution 1

Absolute position

button1.place(x=some_value, y=some_value) 

or relative position

button1.pack(side=RIGHT, padx=some_value, pady=some_value)

padx, pady - paddings

Solution 2

button1.grid(row = 0, column = 0, padx = 0, pady = 0)

But this cannot be used together with pack(), you need to stick to either one.

And this only orders objects relatively, so if you have only one object and you set the row and column to 40 and 50, respectively, the object will still be on the top left corner.

Share:
12,136
Jonah Fleming
Author by

Jonah Fleming

I am a new Python programmer who likes creating and distributing free Tkinter apps. I am SOreadytohelp

Updated on June 04, 2022

Comments

  • Jonah Fleming
    Jonah Fleming almost 2 years

    I am new to Python and Tkinter and I am needing to move a button.

    I have been using button1.pack() to place the button.

    I am not able to move the button from its original position at the bottom of the screen.

  • Jonah Fleming
    Jonah Fleming almost 9 years
    Thank you. Does this mean I have to only use grid()? Can I use pack in other sections?
  • Ekin Deniz Aksu
    Ekin Deniz Aksu almost 9 years
    You can use them in the same script, but not in the same tkinter master window. Also, this website gives you an overview with nice examples: python-course.eu/tkinter_layout_management.php