How to insert into listbox using wxPython

Andrew na
Fri Jan 9 15:10:28 EST 2004


Hi thanks for your help but I am still having problems basically I am using
a button to connect to a Database and I want to display the data from the
database into the listbox
Here is the code I am using for the button

    def OnB2Button(self, event):
        self.db = MySQLdb.connect("localhost", "", "", "guestbook")
        global db
        self.c = self.db.cursor()
        self.c.execute("SELECT * FROM guests;")
        self.results = self.c.fetchall()
        # Here is where I don't know what to do I want to be able to get the
data from self.results and display it in the listbox
        self.listbox.Append('')
        self.listbox.Set([''])
        self.listbox.Delete(0)
        print self.listbox.GetSelections()
        self.sizer.Add(self.listbox, 0, wxEXPAND)
        self.Set.Sizer(self.sizer)

Thank you again for your help

Cheers

Andrew





More information about the Python-list mailing list