Tkinnter questions
Rodolphe
robloche at fr.st
Sat Nov 2 20:00:22 EST 2002
> 1- the window always appears in the upper left corner of my screen -
> how can I make it appear at the center of the screen ?
Hi, just call this function before enter the "mainloop" :
def centerWidget(widget):
top = widget.winfo_toplevel()
sw = top.winfo_screenwidth()
sh = top.winfo_screenheight()
w = top.winfo_width()
h = top.winfo_height()
x = (sw - w)/2
y = (sh - h)/2
geom = '%dx%d+%d+%d' % (w, h, x, y)
top.geometry(geom)
centerWidget(tkRoot)
tkRoot.mainloop()
More information about the Python-list
mailing list