def addCharacter(self, event):
        name = self.sName.GetValue()
        gen = self.sGen.GetValue()
        age = self.sAge.GetValue()
        occ = self.sOcc.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
        dbprogramGUI.newCharacter(name, gen, age, occ)
        print dbprogramGUI.viewAll()

        # Empty text boxes when finished.
        self.sName.Clear()
        self.sGen.Clear()
        self.sOcc.Clear()
        self.sAge.SetValue(0)

        # Update list control
        self.fillListCtrl()
Esempio n. 2
0
    def fillListCtrl(self):
        # Get data from the database
        allData = dbprogramGUI.viewAll()

        # Delete old data before adding new data
        self.listCtrl.DeleteAllItems()

        # Append data to the table
        for row in allData:
            # Loop though and append data
            self.listCtrl.Append(row)