Tkinter - centering, positioning new windows

Christian Tanzer tanzer at swing.co.at
Sat Mar 11 04:05:59 EST 2000


Thomas Lane <tom at parlant.com> wrote

> Does anyone know how to specify the position of a Toplevel window? I
> haven't been able to find any documentation on this. I would especially
> like to be able to center a window on the screen and center a window
> respective to its parent window. I know this must be possible, since
> dialogs popped up by TkMessageBox do this. As usual, any help would be
> greatly appreciated.

`wm_geometry' allows setting the size and/or position of a toplevel
window. The argument to it is a string of the form

    "%dx%d+%d+%d" % (width, height, x_position, y_position)

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92





More information about the Python-list mailing list