Geometry option in Tk()

Matthew Dixon Cowles matt at mondoinfo.com
Sun Feb 9 14:55:05 EST 2003


On Sun, 09 Feb 2003 19:22:17 GMT, Sam Marrocco
<samSPAMMENOT at twmi.rr.com> wrote:

> Using TK, I've got a window that I can set the size of using the
> toplevel widget.....but even thought the window changes sizes
> according to my .geometry option, I can't "read" the information
> back from the toplevel widget correctly.....

> root=Tk()
> root.geometry("50x50+100+100") #Set the window to a size and pos
> print root.geometry()
> >>RETURNS: 1x1+100+100

> The x & y position information is correct, but the width and height
> info always returns as 1 & 1.

> Why would this be if the widget is taking/drawing correctly?

That's one of the, um, quirks of Tkinter. I've never tracked down the
exact reason, but it's generally sufficient to call
root.update_idletasks() before calling root.geometry() to get the
right numbers.

Regards,
Matt





More information about the Python-list mailing list