[Tkinter-discuss] winfo_width problem
fredrik at pythonware.com
Sat Oct 1 16:13:51 CEST 2005
evgeny fadeev wrote:
> 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
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).
> 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.
More information about the Tkinter-discuss