####################################################################################################### # # This is a Python GUI framework for the wftk. # # Copyright (c) 2003-2006, Vivtek, and released under the GPL. # ####################################################################################################### |
import wftk import wxpywf import string from wxPython.wx import * |
d = open (sys.argv[1]) defn = wftk.xml (d.read()) d.close() |
class main_window(wxpywf.frame): def __init__(self, parent, id, dialog): wxpywf.frame.__init__(self, parent, defn, dialog) |
class App(wxApp): def OnInit(self): if defn['mode'] == '': defn['mode'] = 'frame' starter = defn.search (defn['mode'], 'id', defn[defn['mode']]) cli_list = [] #for c in defn.elements(): # if c.is_a('commands') and c['python'] != '': # try: # import c['python'] # cli_list = cli_list + [c['python'].cli(None)] # except: # wxpywf.notify_user ("Attempt to load command line definition %s failed." % c['python']) if starter: frame = main_window(None, defn, starter) self.SetTopWindow(frame) return true else: wxpywf.notify_user ("Starting %s '%s' undefined. Cannot start." % (defn['mode'], defn[defn['mode']])) return false app = App(0) app.MainLoop() |
A note on dynamic loading: see http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/223972 -- describes how to load modules dynamically at runtime based on the configuration file. Useful schtuff. But more than I want to handle right now. TODO: this.
This code and documentation are released under the terms of the GNU license. They are copyright (c) 2002-2006, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation was prepared with LPML. Try literate programming. You'll like it. |