Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move the entire window to a place on the screen (Tkinter, Python3)

The title says it all. How to move the entire window to a place on the screen using tkinter. This should be moving the root frame.

like image 992
Jan Muric Avatar asked Nov 15 '25 17:11

Jan Muric


2 Answers

Use the geometry method of the root (or any Toplevel) window. For example:

import tkinter as tk
root = tk.Tk()
root.geometry("+200+400") # places the window at 200,400 on the screen
like image 67
Bryan Oakley Avatar answered Nov 17 '25 07:11

Bryan Oakley


use this:

from tkinter import Tk

main=Tk()
main.geometry('+100+200')
main.mainloop()

or do it with function :

def change_position(root_variable,x,y):
    root_variable.geometry('+{}+{}'.format(x,y))

and use :change_position(main,500,400)

edit: added dot for format

like image 25
Mohammad Chenarani Avatar answered Nov 17 '25 07:11

Mohammad Chenarani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!