简体   繁体   中英

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.

Use thegeometry 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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM