[pygtk] Combobox with thousands of rows
Walter Leibbrandt
walter at translate.org.za
Thu Mar 26 19:35:03 WST 2009
Rob Brown-Bayliss wrote:
> 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.
Have you tried using multiple columns? gtk.ComboBox.set_wrap_width()
> Does any one have an idea or solution that does not take up too much
> screen space.
If your users have a good idea of what is in the collection or what
they're searching for, you could use a gtk.Entry with an associated
gtk.EntryCompletion (or even a gtk.ComboBoxEntry with completion). I
have used EntryCompletions in Spelt
(https://translate.svn.sourceforge.net/svnroot/translate/src/trunk/spelt/spelt/gui/edit_area.py)
and added some optimization hacks:
* Line 542: The completion is only done once the text in the Entry has
reached a predetermined minimum length.
* Lines 543-548: A timeout is used to implement a delay between the last
change made to the text and starting the completion.
* Method _complete_root(): A filtered TreeModel is used as the
completion's model.
This approach has been tested with 100 000 rows and was still usable,
although slightly slow.
If, on the other hand, your users have no knowledge about the data they
are looking for, then your best bet is probably a TreeView.
--
Walter Leibbrandt Software Developer
Recent blogs:
* Firefox-style button with a pop-up menu
http://www.translate.org.za/blogs/walter/en/content/firefox-style-button-pop-menu
More information about the pygtk
mailing list