class EventTest(Caption1Events): def onHTMLMouseMoved(self, sender, x, y): pass def onUILoaded(self, text): self.b = Builder(text) caption1events = Caption1Events(self) builderevents = BuilderEvents(self) self.caption1 = self.b.createInstance("CaptionPanel1", caption1events) self.caption2 = self.b.createInstance("CaptionPanel2", self) self.login = self.b.createInstance("AppLogin", self) self.bp = BuilderPanel(PanelInstanceName="Grid1", InstanceName="builderpanel", Builder=self.b, EventReceiver=builderevents) RootPanel().add(self.caption1) RootPanel().add(self.caption2) RootPanel().add(self.bp) def onUILoadingTimeout(self, text, code): print "timeout loading UI", text, code def onUILoadError(self, text, code): print "error loading UI", text, code
def onUILoaded(self, text): self.b = Builder(text) caption1events = Caption1Events(self) builderevents = BuilderEvents(self) self.caption1 = self.b.createInstance("CaptionPanel1", caption1events) self.caption2 = self.b.createInstance("CaptionPanel2", self) self.login = self.b.createInstance("AppLogin", self) self.bp = BuilderPanel(PanelInstanceName="Grid1", InstanceName="builderpanel", Builder=self.b, EventReceiver=builderevents) RootPanel().add(self.caption1) RootPanel().add(self.caption2) RootPanel().add(self.bp)
def onUILoaded(self, text): self.b = Builder(text) self.mp = self.b.createInstance("MainPanel", self) # tab panel self.mp.fTabs.add(cPatientsummaryPanel(), "Patient summary") self.mp.fTabs.add(HTML("Panel 2"), "Tab2") self.mp.fTabs.add(HTML(""), None) # spacer self.mp.fTabs.add(cTestPanel(), "RPC Test") self.mp.fTabs.add(HTML("This is a Test.<br />Tab should be on right"), "Test") self.mp.fTabs.selectTab(0) self.searchpanel = cPatientsearchPanel() self.mp.insert(self.searchpanel, 1)
class cMainPanel(cOpenCommand, cSaveCommand, cLogoutCommand): def __init__(self): HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done def onUILoaded(self, text): self.b = Builder(text) self.mp = self.b.createInstance("MainPanel", self) # tab panel self.mp.fTabs.add(cPatientsummaryPanel(), "Patient summary") self.mp.fTabs.add(HTML("Panel 2"), "Tab2") self.mp.fTabs.add(HTML(""), None) # spacer self.mp.fTabs.add(cTestPanel(), "RPC Test") self.mp.fTabs.add(HTML("This is a Test.<br />Tab should be on right"), "Test") self.mp.fTabs.selectTab(0) self.searchpanel = cPatientsearchPanel() self.mp.insert(self.searchpanel, 1) def getPanel(self): return self.mp def onMenuItemRegisterPerson(self): print "TODO: register person"
class cPatientSelector: """ Patient Selector. """ def __init__(self, patients): self.ps = None self.patients = patients HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done #-------------------------------------------------- def onUILoaded(self, text): self.b = Builder(text) self.ps = self.b.createInstance("PatientSelect", self) self.fill_grid() self.ps.centerBox() self.ps.show() #-------------------------------------------------- def getPanel(self): return self.ps #-------------------------------------------------- def fill_grid(self): grid = self.ps.vp.sp.grid grid.resize(1+len(self.patients), 3) for (row, patient) in enumerate(self.patients): grid.setHTML(row+1, 0, patient.description) grid.setHTML(row+1, 1, patient.formatted_dob) grid.setHTML(row+1, 2, patient.xmin_identity) #-------------------------------------------------- def onPatientCellClicked(self, sender, row, col): if row == 0: return patient = self.patients[row-1] GMWevents.events.onPatientSelectedEvent(self, patient) self.ps.hide() #-------------------------------------------------- def onPatientSelectOk(self, sender): self.ps.hide() #-------------------------------------------------- def onPatientSelectCancel(self, sender): self.ps.hide()
class cPatientSelector: """ Patient Selector. """ def __init__(self, patients): self.ps = None self.patients = patients HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done #-------------------------------------------------- def onUILoaded(self, text): self.b = Builder(text) self.ps = self.b.createInstance("PatientSelect", self) self.fill_grid() self.ps.centerBox() self.ps.show() #-------------------------------------------------- def getPanel(self): return self.ps #-------------------------------------------------- def fill_grid(self): grid = self.ps.vp.sp.grid grid.resize(1 + len(self.patients), 3) for (row, patient) in enumerate(self.patients): grid.setHTML(row + 1, 0, patient.description) grid.setHTML(row + 1, 1, patient.formatted_dob) grid.setHTML(row + 1, 2, patient.xmin_identity) #-------------------------------------------------- def onPatientCellClicked(self, sender, row, col): if row == 0: return patient = self.patients[row - 1] GMWevents.events.onPatientSelectedEvent(self, patient) self.ps.hide() #-------------------------------------------------- def onPatientSelectOk(self, sender): self.ps.hide() #-------------------------------------------------- def onPatientSelectCancel(self, sender): self.ps.hide()
class cPatientInboxPanel(SimplePanel): """ Patient Inbox Messages. derives from SimplePanel so that it can be added immediately to cPatientsummaryPanel and then, when HTTPUILoader picks up the XML file (asynchronously), the PatientInbox instance can be added then. """ def __init__(self, **kwargs): SimplePanel.__init__(self, **kwargs) self.pp = None self.active_patient_messages = [] self.active_patient_id = None self.TEXT_WAITING = "Waiting for response..." HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done #-------------------------------------------------- def onUILoaded(self, text): self.b = Builder(text) self.pp = self.b.createInstance("PatientInbox", self) GMWevents.events.addPatientSelectedListener(self) GMWevents.events.addLoginListener(self) self.add(self.pp) #-------------------------------------------------- def getPanel(self): return self.pp #-------------------------------------------------- def fill_grid(self): fill_grid_messages(self.pp.grid, self.active_patient_messages) #-------------------------------------------------- def onPatientSelected(self, sender, patient_info): if self.logged_in and patient_info is not None: self.active_patient_id = patient_info.pk_identity self.active_patient_messages = None Remote.svc.get_patient_messages(self.active_patient_id, self) else: self.active_patient_id = None self.active_patient_messages = [] print "patient id", self.active_patient_id self.fill_grid() #-------------------------------------------------- def onLogin(self, sender, username, logged_in): self.logged_in = logged_in #-------------------------------------------------- def onRemoteResponse(self, response, request_info): method = request_info.method if method == 'get_provider_inbox_data': self.messages = response self.fill_grid() elif method == 'get_patient_messages': self.active_patient_messages = response self.fill_grid() #-------------------------------------------------- def onRemoteError(self, code, errobj, request_info): # onRemoteError gets the HTTP error code or 0 and # errobj is an jsonrpc 2.0 error dict: # { # 'code': jsonrpc-error-code (integer) , # 'message': jsonrpc-error-message (string) , # 'data' : extra-error-data # } message = errobj['message'] if code != 0: self.setStatus("HTTP error %d: %s" % (code, message)) else: code = errobj['code'] if message['message'] == 'Cannot request login parameters.': self.setStatus("You need to log in first") else: self.setStatus("JSONRPC Error %s: %s" % (code, message))
def onUILoaded(self, text): self.b = Builder(text) self.pp = self.b.createInstance("PatientInbox", self) GMWevents.events.addPatientSelectedListener(self) GMWevents.events.addLoginListener(self) self.add(self.pp)
def onUILoaded(self, text): self.b = Builder(text) self.ps = self.b.createInstance("PatientSelect", self) self.fill_grid() self.ps.centerBox() self.ps.show()
class cLoginPanel: def __init__(self): self.lp = None self.TEXT_WAITING = "Waiting for response..." HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done def onUILoaded(self, text): self.b = Builder(text) self.lp = self.b.createInstance("LoginPanel", self) GMWevents.events.onLoginEvent(self, None, False) # indicate logged out def setStatus(self, txt): if self.lp is not None: self.lp.status.setText(txt) def getPanel(self): return self.lp #-------------------------------------------------- def onLoginClicked(self, sender): self.setStatus(self.TEXT_WAITING) self.lp.button_login.setEnabled(False) # disable whilst checking self.try_user = self.lp.CaptionPanel1.Grid1.username.getText() passwd = self.lp.CaptionPanel1.Grid1.password.getText() self.lp.CaptionPanel1.Grid1.password.setText("") # reset to blank Remote.svc.login(self.try_user, passwd, self) #-------------------------------------------------- def onRemoteResponse(self, response, request_info): method = request_info.method if method == 'login': self.lp.button_login.setEnabled(True) # re-enable after response if response: # XXX response should really contain the username self.setStatus("Login successful: %s" %str(response)) user = self.try_user GMWevents.events.onLoginEvent(self, user, True) self.setStatus("Connected as: %s" % user) else: self.setStatus("Login failed: %s" %str(response)) #-------------------------------------------------- def onRemoteError(self, code, errobj, request_info): # onRemoteError gets the HTTP error code or 0 and # errobj is an jsonrpc 2.0 error dict: # { # 'code': jsonrpc-error-code (integer) , # 'message': jsonrpc-error-message (string) , # 'data' : extra-error-data # } message = errobj['message'] self.lp.button_login.setEnabled(True) # re-enable after response if code != 0: self.setStatus("HTTP error %d: %s" % (code, message)) else: code = errobj['code'] if message['message'] == 'Cannot request login parameters.': self.setStatus("You need to log in first") else: self.setStatus("JSONRPC Error %s: %s" % (code, message))
def onUILoaded(self, text): self.b = Builder(text) self.pp = self.b.createInstance("ProviderInbox", self) GMWevents.events.addPatientSelectedListener(self) GMWevents.events.addLoginListener(self) self.add(self.pp)
class cProviderInboxPanel(SimplePanel): """ Provider Inbox Messages. derives from SimplePanel so that it can be added immediately to cPatientsummaryPanel and then, when HTTPUILoader picks up the XML file (asynchronously), the ProviderInbox instance can be added then. """ def __init__(self, **kwargs): SimplePanel.__init__(self, **kwargs) self.pp = None self.messages = [] self.active_patient_id = None self.TEXT_WAITING = "Waiting for response..." HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done # -------------------------------------------------- def onUILoaded(self, text): self.b = Builder(text) self.pp = self.b.createInstance("ProviderInbox", self) GMWevents.events.addPatientSelectedListener(self) GMWevents.events.addLoginListener(self) self.add(self.pp) # -------------------------------------------------- def getPanel(self): return self.pp # -------------------------------------------------- def fill_grid(self): show_active_only = self.pp.hpShow.rdbActive.getChecked() if show_active_only and self.active_patient_id: messages = [] for item in self.messages: if item.pk_patient == self.active_patient_id: messages.append(item) else: messages = self.messages fill_grid_messages(self.pp.grid, messages) # -------------------------------------------------- def onAllMessagesSelected(self, sender): print "all selected" print self.pp.hpShow.rdbActive._clickListeners self.fill_grid() # -------------------------------------------------- def onPatientMessagesSelected(self, sender): print "patient selected" self.fill_grid() # -------------------------------------------------- def onPatientSelected(self, sender, patient_info): if patient_info is not None: self.active_patient_id = patient_info.pk_identity else: self.active_patient_id = None print "patient id", self.active_patient_id self.fill_grid() # -------------------------------------------------- def onLogin(self, sender, username, logged_in): self.logged_in = logged_in Remote.svc.get_provider_inbox_data(self) # -------------------------------------------------- def onRemoteResponse(self, response, request_info): method = request_info.method if method == "get_provider_inbox_data": self.messages = response self.fill_grid() # -------------------------------------------------- def onRemoteError(self, code, errobj, request_info): # onRemoteError gets the HTTP error code or 0 and # errobj is an jsonrpc 2.0 error dict: # { # 'code': jsonrpc-error-code (integer) , # 'message': jsonrpc-error-message (string) , # 'data' : extra-error-data # } message = errobj["message"] if code != 0: self.setStatus("HTTP error %d: %s" % (code, message)) else: code = errobj["code"] if message["message"] == "Cannot request login parameters.": self.setStatus("You need to log in first") else: self.setStatus("JSONRPC Error %s: %s" % (code, message))
def onUILoaded(self, text): self.b = Builder(text) self.lp = self.b.createInstance("LoginPanel", self) GMWevents.events.onLoginEvent(self, None, False) # indicate logged out