def addCharacter(self, event): name = self.cName.GetValue() gen = self.cGen.GetValue() age = self.cAge.GetValue() occ = self.cOcc.GetValue() # checking if variables have a value if (name == '') or (gen == '') or (age == '') or (occ == ''): # alert user that a variable is empty dlg = wx.MessageDialog( None, 'Some character details are missing. Enter values in each text box.', 'Missing Details', wx.OK) dlg.ShowModal() dlg.Destroy() return False # adding character to database pythonday2part4gui2database.newCharacter(name, gen, age, occ) print pythonday2part4gui2database.viewAll() print name print gen print age print occ # empty text boxes when finished. self.cName.Clear() self.cGen.Clear() self.cOcc.Clear() self.cAge.SetValue(0) # update list control self.fillListCtrl()
def addCharacter(self, event): name = self.cName.GetValue() gen = self.cGen.GetValue() age = self.cAge.GetValue() occ = self.cOcc.GetValue() # checking if variables have a value if (name =='') or (gen=='') or (age=='') or (occ==''): # alert user that a variable is empty dlg = wx.MessageDialog(None, 'Some character details are missing. Enter values in each text box.', 'Missing Details', wx.OK) dlg.ShowModal() dlg.Destroy() return False # adding character to database pythonday2part4gui2database.newCharacter(name, gen, age, occ) print pythonday2part4gui2database.viewAll() print name print gen print age print occ # empty text boxes when finished. self.cName.Clear() self.cGen.Clear() self.cOcc.Clear() self.cAge.SetValue(0) # update list control self.fillListCtrl()
def fillListCtrl(self): allData = pythonday2part4gui2database.viewAll() # delete old data before adding new data self.listCtrl.DeleteAllItems() for row in allData: # loop through and append data self.listCtrl.Append(row)