Discussion:
[Tkinter-discuss] winfo_width problem
evgeny fadeev
2005-09-30 21:34:16 UTC
Permalink
Hi,
i am trying to use winfo_width to determine widget's size
and it always returns me 1 regardless of wheter widget is packed/gridded or
not.

in native Tcl/Tk
winfo width .widget
works fine, i.e. returns actual width in pixels

direct tk call from python tk.call('winfo','width',widget._w) still returns
1

i guess it points to some bug in tkinter ...... what do you think?

Thanks.
Evgeny.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
Gustavo Henrique Cervi
2005-09-30 21:42:06 UTC
Permalink
Try using "winfo_reqheight(), winfo_reqwidth()"

...

winfo_reqheight(), winfo_reqwidth(). Return the "natural" height (width)
for self. The natural size is the minimal size needed to display the
widget's contents, including padding, borders, etc. This size is
calculated by the widget itself, based on the given options. The actual
widget size is then determined by the widget's geometry manager, based
on this value, the size of the widget's master, and the options given to
the geometry manager.


[]'s
-Gustavo
Post by evgeny fadeev
Hi,
i am trying to use winfo_width to determine widget's size
and it always returns me 1 regardless of wheter widget is packed/gridded or
not.
in native Tcl/Tk
winfo width .widget
works fine, i.e. returns actual width in pixels
direct tk call from python tk.call('winfo','width',widget._w) still returns
1
i guess it points to some bug in tkinter ...... what do you think?
Thanks.
Evgeny.
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
Fredrik Lundh
2005-10-01 14:13:51 UTC
Permalink
Post by evgeny fadeev
i am trying to use winfo_width to determine widget's size
and it always returns me 1 regardless of wheter widget is
packed/gridded or not.
in native Tcl/Tk
winfo width .widget
works fine, i.e. returns actual width in pixels
direct tk call from python tk.call('winfo','width',widget._w) still returns
1
the actual width and height is set by an idle task when the widget
is prepared for drawing. idle tasks are executed by the event loop,
so you will usually have to call "update_idletasks" or "update" before
querying the size (event handlers are one exception to that rule).

reqwidth/reqheight is often a good alternative (see Gustavo's reply).
Post by evgeny fadeev
i guess it points to some bug in tkinter ...... what do you think?
it's the way things work under Tkinter. if you want Tkinter to process
events, you have to give it a chance to do that.

</F>

Loading...