[pygtk] Combobox with thousands of rows

Neil Dugan pygtk at butterflystitches.com.au
Thu Mar 26 15:51:27 WST 2009


Rob Brown-Bayliss wrote:
> Hi.  
> 
> I need a way to let users pick one of approx 8000 names from a list and
> had thought to use a combobox but it is far too slow taking several
> seconds to pop up, and scrolling is unusable.
> 
> Does any one have an idea or solution that does not take up too much
> screen space.
> 
> here is the code I was usign to load the list:
> 
> 		custs = self.DB.select("SELECT CAST(Customer_Key as TEXT), CAST(Name
> as Text) FROM Customer Order By Name")
>                 cust_list =
> gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_STRING)
> 		if custs != None:
> 			for c in custs:
> 				n = c[1].strip()
> 				row = (unicode(n),c[0])
> 				cust_list.append(row)       	
> 		self.customer.set_model(cust_list)	
> 
> 
> 
> --
> Rob Brown-Bayliss
> 
> http://globalvillage.sourceforge.net 
> The world at your finger tips...
> 
> 

I would use a gtk.TreeStore() model in a gtk.TreeView() widget.  Using 
the first one or two letters of the name for the tree nodes.

Maybe in a Dialog window if there isn't space for the gtk.TreeView() 
in the GUI.

It is possible use a lazy mode and only populate the gtk.TreeStore() 
as the user clicks on the appropriate nodes.

Regards Neil.



More information about the pygtk mailing list