Instead of using self.__dict__ which iterates over all objects that
you have, you should make a separate self.widgets dictionary that
contains specifically only the widgets you want to clear.
Then you can also use dict.values() trick to make your loop simpler:
self.widgets['alpha'] = gtk.CheckButton.new()
self.widgets['beta'] = gtk.CheckButton.new()
[etc...]
for widget in self.widgets.values():
print type(widget)
widget.set_active(False)
On Tue, Dec 28, 2010 at 9:06 AM, <[email protected]> wrote:
>
>
> From: [email protected]
> Sent: Tuesday, December 28, 2010 4:41 PM
> To: [email protected]
> 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
>
> _______________________________________________
> pygtk mailing list [email protected]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
--
http://exolucere.ca
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/