Tkinter - centering, positioning new windows

Christian Tanzer tanzer at swing.co.at
Sun Mar 12 02:06:09 EST 2000


"Fredrik Lundh" <effbot at telia.com> wrote:

> > >     "%dx%d%+d%+d" % (width, height, x_position, y_position)
> > 
> > Could you explain that, please?
> > 
> > Both Tkinter and Idle use 
> > 
> >     "+%d+%d" % (x, y)
> 
> that doesn't work if x or y is negative.

Ahhh, of course.

Do negative x and y work on all platforms or is this just another
Unixism? 

> (couldn't find a single trace of "%d" in the Tkinter
> sources, btw.  what version are you using?)

1.5.2.

It's not in Tkinter.py proper, but in auxiliary files:

-------------------------------------------------------------------------------
tanzer [code] 1 $ agrep 'geometry#%' /usr/src/Python-1.5.2/Lib/lib-tk/*.py
/usr/src/Python-1.5.2/Lib/lib-tk/SimpleDialog.py:
         widget.geometry("+%d+%d" % (x, y))
/usr/src/Python-1.5.2/Lib/lib-tk/tkSimpleDialog.py:
         self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
-------------------------------------------------------------------------------

Regards,
Christian

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