[EMAIL PROTECTED] wrote:
> 
> >       I use the class so that I can have a common namespace, but importing 
>__main__ every time I want to access it seems not only ugly, but "wrong" due to the 
>lack
> > of modularity. Is there a better way I can write/structure this program's 
>namespace?
> 
> This is the code I wrote to solve this for SQmaiL:
>
        <snip>
>
> Now I can do "self.widget.glade_widget_name" and it will automatically look up
> "glade_widget_name" in the tree and return it to me (all cached so it's fast).
> What's more, I can tell Glade to connect a button to the signal
> "on_quit" and when I press it, the "on_quit()" method is
> automatically invoked:
> 
> ---snip---
>         def on_quit(self, obj):
>                 sys.exit(0)
> ---snip---
> 
> Very, very handy. It could hardly make development with Glade and Python easier.
> Python is a Good Thing.


        That is in fact quite useful, and I've managed to figure out how to adjust my 
handling of the various widgets, except for when I want to hide the window, which
isn't in the main application's widget tree:

def on_game_information_togglebutton_toggled(self, obj):
    print self.widget.game_information_togglebutton.get_active()

    if (self.widget.game_information_togglebutton.get_active() == 1):
        self.readglade("game_information_editor")
        #self.widget.game_information_editor.show()
    else:
        self.widget.game_information_editor.hide()


        I had to comment out the "show" command because it seems to be implicit now. I 
understand that once a widget is loaded I can address it by self.widget.<widget
name> but that doesn't seem to work for my popup window (in the else clause):

  File "./CogDevApp2.py", line 31, in __getattr__
    raise AttributeError("Widget "+attr+" not found")
AttributeError: Widget game_information_editor not found

        My understanding of what's happening here is admittedly shaky, but I am under 
the impression that "self.widget.<name>" only works for widgets/components which
are stored within the "parent" application window. How can I access the window widget, 
which is stored in the other tree?

-- 
Steve Castellotti
Systems Programmer
School of Arts and Sciences, University of Pennsylvania

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to