def __init__(self, idx): wx.Dialog.__init__(self, None, -1, "Patent Details", size=(700, 600)) ''' Constructor ''' self.gpTable = GPTable() self.tableData = GPTableData() if idx != -1: self.data = self.gpTable.showItem(idx) print self.data else: self.data = (1, None, u'Steve', u'Dean', None, None, None, None, None, None, None, None) self.panel = PatentEditPanel(self, self.tableData, self.data) sizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.panel, 1, wx.EXPAND) okButton = wx.Button(self, wx.ID_OK, "Ok", pos=(15, 15)) okButton.SetDefault() btnSizer.Add(okButton) cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel", pos=(15, 15)) btnSizer.Add(cancelButton) sizer.Add(btnSizer) self.SetSizer(sizer) self.SetInitialSize()
def test32(self): ''' Select first name and surname ''' pa = GPTable() rows = pa.selectcols(idx=True, first_name=True, surname=True) for row in rows: print row
def __init__(self, parent, style=wx.TAB_TRAVERSAL): super(GPCtrl, self).__init__(parent, style=style) self.backupsListCtrl = BackupListCtrl(self) self.gpTable = GPTable() rows = self.gpTable.showAll() self.rowManager = RowManager(rows) self.backupsListCtrl.populateList(self.rowManager.Get()) # Layout self.__DoLayout() self.SetInitialSize()
def NewGP(self): gpTable = GPTable() gpTable.add(self.gpGeneralPage.first.GetValue(), self.gpGeneralPage.surname.GetValue(), address=self.gpGeneralPage.address.GetValue(), town=self.gpGeneralPage.town.GetValue(), post_code=self.gpGeneralPage.postcode.GetValue(), home_phone=self.gpGeneralPage.homephone.GetValue(), work_phone=self.gpGeneralPage.workphone.GetValue(), mobile=self.gpGeneralPage.mobile.GetValue(), prefered_phone=self.gpGeneralPage.preferedPhone.GetValue(), email=self.gpGeneralPage.email.GetValue()) #self.gpGeneralPage.title.GetValue() '''
class GPEditDialog(wx.Dialog): ''' classdocs ''' def __init__(self, idx): wx.Dialog.__init__(self, None, -1, "Patent Details", size=(700, 600)) ''' Constructor ''' self.gpTable = GPTable() self.tableData = GPTableData() if idx != -1: self.data = self.gpTable.showItem(idx) print self.data else: self.data = (1, None, u'Steve', u'Dean', None, None, None, None, None, None, None, None) self.panel = PatentEditPanel(self, self.tableData, self.data) sizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.panel, 1, wx.EXPAND) okButton = wx.Button(self, wx.ID_OK, "Ok", pos=(15, 15)) okButton.SetDefault() btnSizer.Add(okButton) cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel", pos=(15, 15)) btnSizer.Add(cancelButton) sizer.Add(btnSizer) self.SetSizer(sizer) self.SetInitialSize() #self.Bind(wx.EVT_BUTTON, self.OnButton) def OnButton(self, event): if event == wx.ID_OK: self.Save() def Save(self): cl = self.tableData.updateList() if len(cl): self.gpTable.updatelist(1, cl) return True return False def GetUsername(self): self.panel.GetUsername() def GetPassword(self): self.panel.GetPasswd()
def test34(self): pa = GPTable() for i in range(5,13): pa.update(i, home_phone='01444-241048') where = pa.singlewhere(work_phone='01444-241048') rows = pa.selectall(whereStr=where) for row in rows: print row
def test33(self): pa = GPTable() idx = pa.get_id("Paul", "Limb") assert idx != None, "Item not found" row = pa.showItem(idx) print row
def test31(self): ''' Selete all data ''' pa = GPTable() rows = pa.selectall() n = len(rows) assert n == 35, "Need to have 35 rows "
def test30(self): ''' Initalise Table with date ''' pa = GPTable() pa.add("Steve", "Dean") pa.add("Stephen", "Bennett") pa.add("Stephen", "Brunton") pa.add("Simon", "Robinson") pa.add("Roger", "Smith") pa.add("Robert", "Poole") pa.add("Robert", "Gardner") pa.add("Richard", "Howell") pa.add("Richard", "Fewing") pa.add("Richard", "Carter") pa.add("Peter", "King") pa.add("Peter", "Connolly") pa.add("Paul", "Limb") pa.add("Paul", "Leeming") pa.add("Paul", "Hill") pa.add("Paul", "Arthurs") pa.add("Paul", "Bergin") pa.add("Paul", "Arnold") pa.add("Nigel", "Williams") pa.add("Neville", "Smith") pa.add("Neil", "Clark") pa.add("Mike T", "Robson") pa.add("Michael", "Peirce") pa.add("Max", "Borkowski") pa.add("Martin", "Kirby") pa.add("Mark", "Stanley") pa.add("Mark", "Ingram") pa.add("Mark", "Collins") pa.add("Malcolm", "Stenning") pa.add("Louis", "Kenney") pa.add("Leon", "Tanner") pa.add("Krystyn", "Rogers") pa.add("Kevin", "Ellwood") pa.add("Steve", "Kersley") pa.add("dave","fresdrickson" )
class GPCtrl(scrolledpanel.ScrolledPanel): pageName = "GPPage" def __init__(self, parent, style=wx.TAB_TRAVERSAL): super(GPCtrl, self).__init__(parent, style=style) self.backupsListCtrl = BackupListCtrl(self) self.gpTable = GPTable() rows = self.gpTable.showAll() self.rowManager = RowManager(rows) self.backupsListCtrl.populateList(self.rowManager.Get()) # Layout self.__DoLayout() self.SetInitialSize() def __DoLayout(self): title_lbl = wx.StaticText(self, label="General Practitioners") font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL) title_lbl.SetFont(font) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(title_lbl, 0, wx.ALL, 5) mainSizer.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) sizer = wx.GridBagSizer(vgap=2, hgap=2) nameLbl = wx.StaticText(self, -1, "Name:") title = '' first = '' surname = '' nameStr = title + " " + first + " " + surname self.name = wx.StaticText(self, -1, nameStr) sizer.Add(nameLbl, (1, 1)) sizer.Add(self.name, (1, 2)) addressLbl = wx.StaticText(self, -1, "Address:") address1 = '' town = '' county = '' postcode = '' address1Str = address1 + " " + " " + town self.address = wx.StaticText(self, -1, address1Str) self.county = wx.StaticText(self, -1, county) self.post = wx.StaticText(self, -1, postcode) sizer.Add(addressLbl, (2, 1)) sizer.Add(self.address, (2, 2)) sizer.Add(self.county, (3, 2)) sizer.Add(self.post, (4, 2)) phoneLbl = wx.StaticText(self, -1, "Phone:") phoneStr = '' mobileStr = '' sizer.Add(phoneLbl, (5, 1)) self.phone = wx.StaticText(self, -1, phoneStr) self.mobile = wx.StaticText(self, -1, mobileStr) sizer.Add(self.phone, (5, 2)) sizer.Add(self.mobile, (6, 2)) emailLbl = wx.StaticText(self, -1, "Email:") emailStr = "*****@*****.**" self.email = wx.StaticText(self, -1, emailStr) sizer.Add(emailLbl, (7, 1)) sizer.Add(self.email, (7, 2)) btnszr = wx.StdDialogButtonSizer() editbtn = wx.Button(self, wx.ID_EDIT) openbtn = wx.Button(self, wx.ID_OPEN) editbtn.SetDefault() sizer.Add(editbtn, (8, 3)) sizer.Add(openbtn, (8, 4)) btnszr.Realize() listSizer = wx.GridBagSizer(vgap=2, hgap=2) listSizer.Add(self.backupsListCtrl, (1, 1)) mainSizer.Add(sizer, 0, wx.EXPAND | wx.ALL, 10) #mainSizer.Add(btnszr, 0, wx.ALIGN_LEFT, 12) mainSizer.Add(listSizer, 0, wx.EXPAND | wx.ALL, 10) self.SetSizer(mainSizer) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClicked) def OnClicked(self, event): self.selected_row = event.GetIndex() rows = self.rowManager.Get() row = rows[self.selected_row] idx = row[GPTable.IDX_GP_ID] gpEditDialog = GPEditDialog(idx) print "Opening CPDEditDialog" if gpEditDialog.ShowModal() == wx.ID_OK: if gpEditDialog.Save(): row = self.gpTable.showItem(idx) self.rowManager.update(row) self.backupsListCtrl.populateList(self.rowManager.Get()) print "Closing CPDEditDialog" def OnItemSelected(self, event): self.selected_row = event.GetIndex() val = list() for column in range(1, 3): item = self.backupsListCtrl.GetItem(self.selected_row, column) val.append(item.GetText()) frame = self.GetTopLevelParent() frame.PushStatusText(" ".join(val)) rows = self.rowManager.Get() row = rows[self.selected_row] self.AddressUpdate(row) def DBStr(self, data): if data == None: return "" return data def AddressUpdate(self, row): title = self.DBStr(row[PatentTable.IDX_TITLE]) first = self.DBStr(row[PatentTable.IDX_FIRST_NAME]) surname = self.DBStr(row[PatentTable.IDX_SURNAME]) nameStr = "" if title == "": nameStr = first + " " + surname else: nameStr = title + " " + first + " " + surname self.name.SetLabel(nameStr) address = self.DBStr(row[PatentTable.IDX_ADDRESS]) town = self.DBStr(row[PatentTable.IDX_TOWN]) address1Str = address + " " + town self.address.SetLabel(address1Str) county = "West Sussex" postcode = self.DBStr(row[PatentTable.IDX_POST_CODE]) self.county.SetLabel(county) self.post.SetLabel(postcode) Home = self.DBStr(row[PatentTable.IDX_HOME_PHONE]) Work = self.DBStr(row[PatentTable.IDX_WORK_PHONE]) Mobile = self.DBStr(row[PatentTable.IDX_MOBILE]) phoneStr = "Home " + Home + " Work " + Work if Mobile == None: mobileStr = "Mobile " + Mobile else: mobileStr = "" self.phone.SetLabel(phoneStr) self.mobile.SetLabel(mobileStr) email = self.DBStr(row[PatentTable.IDX_EMAIL]) if email != None: self.email.SetLabel(email) else: self.email.SetLabel("")
def test39(self): ''' Delete all data ''' pa = GPTable() pa.deleteall() rows = pa.selectall() assert len(rows) == 0, "Table not empty"