[Tutor] Tkinter - TOP LEVEL WINDOW Questions

Gregor Lingl glingl at aon.at
Tue Jan 27 02:50:37 EST 2004

abc-100036 at apc.edu.ph schrieb:

>I have a problem regarding displaying a new top level window using tkinter codes. Whenever 
>I ran the script. The top level window shows up in the topmost left corner of my screen.  
You have to use winfo_screenwidth() and winfo_screenheight() methods to 
determine screensize
and the use geometry method to place your window.


 >>> from Tkinter import *
 >>> root = Tk()
 >>> w=root.winfo_screenwidth()
 >>> h=root.winfo_screenheight()
 >>> root.geometry("400x300+%d+%d" % ( (w-400)/2, (h-300)/2 ) )

HTH, Gregor

>Given that, how do I make the top level window to display in the center of the screen. 

More information about the Tutor mailing list