[pygtk] setting state of lots unknown widgets in class

spooky.ln at tbs-software.com spooky.ln at tbs-software.com
Wed Dec 29 00:06:35 WST 2010



From: spooky.ln at tbs-software.com 
Sent: Tuesday, December 28, 2010 4:41 PM
To: pygtk at daa.com.au 
Subject: setting state of lots unknown widgets in class
uff sry for bothering, 
my mistake, i forgot basic python knowledge.
must be:

for widget in self.__dict__:
     print type(self.__dict__[widget])




Hi all,
I’m write some app where is N-th widgets.
Widgets are CheckButtons, Entrys and HScales.
Becouse i rewriting this app a lot i never know how much widgets i have .
But i have ‘Clear’ button. This button sets all widgets into ‘clear’ state. but how on N-th widgets ?

with self.__dict__ i have all values from class what i need, but its string type.
i mean this:

for widget in self.__dict__:
    # i know ‘widget’ is now ‘str’ type but forgot about it for now.
    try:
          if type(widget) == gtk.CheckButton:
                 widget.set_active(False)
...
...
...

Do you know what i mean ?   sry for my english.
any idea without using evil ‘eval’. any clear way ?
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20101228/6365b7a8/attachment.html>


More information about the pygtk mailing list