Incorrect stack data when working with tkinter?

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

Incorrect stack data when working with tkinter?

WingIDE - User mailing list
I am working with Tkinter in Wing Pro 5.1.3. When I look at the stack data I am seeing attributes for my widgets that aren't actual object attributes. For example, if I create a ttk.Checkbutton, the stack shows an attribute called text. But, if I actually try to access this attribute (i.e. checkbutton.text) I get an attribute error, as shown in the screen cap.

screencap.png

I know that checkbuttons have a configuration option called text, which can be accessed through cget() (i.e. checkbutton.cget("text") returns "Test Check Button"). It seems that these tk widget "attributes" are being exposed in the stack data as though they are python object attributes. Is this by design? How can I differentiate between python object attributes and these tk widget attributes?


Thanks!

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect stack data when working with tkinter?

WingIDE - User mailing list
On 8/19/15 5:21 PM, Emma Willemsma via wingide-users wrote:
> I am working with Tkinter in Wing Pro 5.1.3. When I look at the stack
> data I am seeing attributes for my widgets that aren't actual object
> attributes. For example, if I create a ttk.Checkbutton, the stack shows
> an attribute called text. But, if I actually try to access this
> attribute (i.e. checkbutton.text) I get an attribute error, as shown in
> the screen cap.

It looks like a ttk.Checkbutton defines keys() and __getitem__() methods
to exposes tk attributes via checkbutton[<name>].  Because of the keys()
and __getitem__(), Wing is displaying the instance as if it were a
dictionary, with the keys and values interspersed with the attributes.
Wing does this because often you want to view an object that defines
keys() and __getitem__() as if it were a dictionary, but I agree that
it's confusing in this instance.

We'll try to improve this in a future release.

Thanks,

John

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect stack data when working with tkinter?

WingIDE - User mailing list
Oh that does make sense. Thanks for clearing that up!

On Wed, 19 Aug 2015 at 17:46 Wing IDE Support <[hidden email]> wrote:
On 8/19/15 5:21 PM, Emma Willemsma via wingide-users wrote:
> I am working with Tkinter in Wing Pro 5.1.3. When I look at the stack
> data I am seeing attributes for my widgets that aren't actual object
> attributes. For example, if I create a ttk.Checkbutton, the stack shows
> an attribute called text. But, if I actually try to access this
> attribute (i.e. checkbutton.text) I get an attribute error, as shown in
> the screen cap.

It looks like a ttk.Checkbutton defines keys() and __getitem__() methods
to exposes tk attributes via checkbutton[<name>].  Because of the keys()
and __getitem__(), Wing is displaying the instance as if it were a
dictionary, with the keys and values interspersed with the attributes.
Wing does this because often you want to view an object that defines
keys() and __getitem__() as if it were a dictionary, but I agree that
it's confusing in this instance.

We'll try to improve this in a future release.

Thanks,

John

_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide