winfo_width problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

winfo_width problem

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
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: winfo_width problem

Gustavo Henrique Cervi
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

evgeny fadeev wrote:

>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
>[hidden email]
>http://mail.python.org/mailman/listinfo/tkinter-discuss
>
>  
>

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: winfo_width problem

Fredrik Lundh
In reply to this post by evgeny fadeev
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
> 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).

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



_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss