def add_MsgWin(self, tw): """ New Task message widget Send an event to the catcher window in the other thread and tell it to create a MsgWin window. tw = TaskWindow of task to be run """ ################################################################ import OTWindow2, MsgWin if self.app: evt = OTWindow2.MsgWinEvt() evt.evt_type = OTWindow2.EVT_NEW # Set event type evt.evt_tw = tw # add task window self.app.catcher.AddPendingEvent(evt); else: OTWindow2.add_MsgWin(tw)
def add_MsgWin(self, tw): """ New Task message widget Send an event to the catcher window in the other thread and tell it to create a MsgWin window. * tw = TaskWindow of task to be run """ ################################################################ import OTWindow2, MsgWin if self.app: evt = OTWindow2.MsgWinEvt() evt.evt_type = OTWindow2.EVT_NEW # Set event type evt.evt_tw = tw # add task window self.app.catcher.AddPendingEvent(evt) else: OTWindow2.add_MsgWin(tw)
def Update(self, Id): """ Update Widget Id Send an event to the catcher window in the other thread and tell it to refresh the display of widget Id * Id = widget Id """ ################################################################ import OTWindow2 evt = OTWindow2.MsgWinEvt() evt.evt_type = OTWindow2.EVT_UPDATE # Set event type evt.evt_Id = Id # Set widget Id self.app.catcher.AddPendingEvent(evt)
def SetLabel(self, Id, label): """ Set Widget label Send an event to the catcher window in the other thread and tell it to Setlabel on window Id to label * Id = widget Id * label = New text to label """ ################################################################ import OTWindow2 evt = OTWindow2.MsgWinEvt() evt.evt_type = OTWindow2.EVT_LABEL # Set event type evt.evt_Id = Id # Set widget Id evt.evt_label = label # add new label text self.app.catcher.AddPendingEvent(evt)
def Message(self, Id, message): """ Write messages in TextCtrl Send an event to the catcher window in the other thread and tell it to append message(s) in widget Id * Id = widget Id (a TextCtrl) * message = either a single string or an array of strings """ ################################################################ import OTWindow2 evt = OTWindow2.MsgWinEvt() evt.evt_type = OTWindow2.EVT_MESS # Set event type evt.evt_Id = Id # Set widget Id evt.evt_mess = message # add task message(s) self.app.catcher.AddPendingEvent(evt)
def Bind(self, Id, handler): """ Set Button event handler Send an event to the catcher window in the other thread and tell it to rebind the event handler on button Id * Id = widget Id * handler = new event handler """ ################################################################ import OTWindow2 evt = OTWindow2.MsgWinEvt() evt.evt_type = OTWindow2.EVT_BIND # Set event type evt.evt_Id = Id # Set widget Id evt.evt_handler = handler # add task window self.app.catcher.AddPendingEvent(evt)
def run(self): """ Note that OTWindow2 is first imported ***here***. This is the second thread. OTWindow2 imports wxPython, if we imported it at the module level instead of in this function, the import would occur in the main thread and wxPython would not run correctly in the second thread. The wxPython GUI MainLoop is run here (i.e. no return) """ ################################################################ try: import OTWindow2 self.app = OTWindow2.OTGUIApp() self.started = True self.app.MainLoop() except TypeError: self.app = None except Exception as e: self.app = None