I'm trying to understand the "best" way to handle the namespace of my
application. I am working on an editing program (written in pygtk, designed with glade)
which consists of a small window with a few togglebuttons. When you depress one of the
buttons, an editing window launches, when you release it, the window gets
hidden.
Right now, I can do this like this (removing extraneous stuff):
class init_widgets:
def __init__(self):
# Create widget tree and connect widgets to their functions
init_widgets.wTree = GladeXML("CogDevApp.glade", "CogDevApp")
dic = {"on_exit1_activate": mainquit,
"on_about_activate": on_about_activate,
"on_game_information_togglebutton_toggled":
on_game_information_togglebutton_toggled}
init_widgets.wTree.signal_autoconnect(dic)
...
def on_game_information_togglebutton_toggled(obj):
gameInformationTogglebutton =
init_widgets.wTree.get_widget("game_information_togglebutton")
print gameInformationTogglebutton.get_active()
import __main__
if (gameInformationTogglebutton.get_active() == 1):
__main__.widgets.gameInformationEditor =
GladeXML("CogDevApp.glade","game_information_editor").get_widget("game_information_editor")
__main__.widgets.gameInformationEditor.show()
else:
__main__.widgets.gameInformationEditor.hide()
...
if __name__ == '__main__':
widgets = init_widgets()
mainloop ()
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?
Also, right now, when I "hide" the editor's window, I lose all of the
information it contains. Is there a way to preserve the information so that it will
still
be there the next time the togglebutton is depressed?
Thanks for any advice anyone can give me.
--
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