Harry Wright <pygtk at avernus.org.uk> escreveu:
Hello
Is there a better way to do autocompletion in a combobox than what I
have done in the code below (attached an EntryCompletion to the entry
box in the ComboBoxEntry). This works, but it seems a bit odd having a
both a pop-down list from the combobox and a pop-up list for the
autocompletion. Can it be done using just the combobox somehow?
Also, is there any simple way to restrict the user to only entering
text
in the list, without manually checking each character as it is entered?
How you it solved this?
Antonio
Thank
you for any help.
Harry.
def fill_combo(self):
# get combobox from glade file
combo = self.xml.get_widget('combo')
# fill list with a column of strings from a database
list = gtk.ListStore(gobject.TYPE_STRING)
query = "SELECT DISTINCT field FROM table ORDER BY field"
cursor = self.conn.cursor()
cursor.execute(query)
rows = cursor.fetchall()
for row in rows:
list.append(row=[row[0]])
cursor.close()
combo.set_model(list)
combo.set_text_column(0)
completion = gtk.EntryCompletion()
completion.set_model(list)
completion.set_minimum_key_length(1)
completion.set_text_column(0)
combo.child.set_completion(completion)
|
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/