From: Sells, F. <fr...@ad...> - 2005-04-08 14:30:19
|
I have a single window PythonCard app plus a few more classes to wrap access to a DB, Serial IO and a directory of jpg's. I would like to pull everything together in a Controller.py module which would be able to access the my PythonCard module (i.e. the one that matches the PythonCard resource file). I started off using the worldclock demo from the samples directory and have significantly gutted it to fit my needs. I cannot seem to find a way to reference the worldclock instance object so that my controller can use it's methods to update the GUI. the snippet I think relates is: app = model.Application(WorldClock) app.MainLoop() I tried doing a "dir()" on app, but didn't recognize anything as giving me access to the instance of WordClock. I realize I could make WorldClock my "Controller", but that's just not the way I see the design. After all this, by questions are: 1. is there a way to reference the instance of WorldClock, or 2. am I looking into the wrong end of the pipe for PythonCard and should I make WorldClock.py my primary controller? I've included the entire source for WorldClock.py below, for what it's worth: #!/usr/bin/python import urllib import os import time import wx from cStringIO import StringIO from PythonCard import graphic, log, model, timer #from PythonCard.log import Log class WorldClock(model.Background): def on_initialize(self, event): self.clockTimer = timer.Timer(self.components.staticTextClock, -1) self.clockTimer.start(1000) # 1 second self.updateDateAndTime() def on_staticTextClock_timer(self, event): self.updateDateAndTime() def updateDateAndTime(self): t = time.strftime("%I:%M %p") if t[0] == "0": t = t[1:] d = time.strftime("%A, %B %d, %Y") self.components.staticTextClock.text = d+" "+t def on_imageButtonWorld_timer(self, event): print "imageButtonWorld_timer" def on_Leave_mouseClick(self, event): print "clicked leave" def on_Arrive_mouseClick(self, event): print "arrive" def on_showHistory_mouseClick(self, event): print "history" def on_close(self, event): self.clockTimer.stop() event.skip() def setEmployee(self, employee): self.components.Name.text = employee.getFullName() bmp = graphic.Bitmap(employee.getPictureFilename()) if employee.LName=='BURRILL': bmp.rotate180(1) def createApplication(): app = model.Application(WorldClock) for d in dir(app):print d app.MainLoop() ##mainloop never returns. if __name__ == '__main__': createApplication() |