How to insert into listbox using wxPython
Brian Kelley
bkelley at wi.mit.edu
Fri Jan 9 08:31:01 EST 2004
Andrew wrote:
> 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
>
> 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([''])
It looks as though you are putting nothing in the listbox.
Append('') adds a blank
and listbox.Set(['']) replaces the listbox with a blank.
Try:
for x in self.results:
self.listbox.Append(x[0])
Brian
More information about the Python-list
mailing list