Robin Dunn wrote:
Jim Carroll wrote:
Hi, I want to do an auto-complete text field that is just
like the address bar in firefox. I tried the masked edit
controls, but they don't actually pop up the options in a
list box under the edit field. I could use a very small Scite
control...But I'm wondering if anyone knows of an implementation
that uses a plain TextCtrl for auto-complete?http://wiki.wxpython.org/index.cgi/TextCtrlAutoComplete
There was also some discussion about it on this list in February.
I had missed this discussion, and given that this seemed similar to
my own masked.ComboBox functionality, I went and tried the code above.
First, let me say I was very impressed, and think this is a terrific
control--good work and kudos to Edward Flick and Michele Petrazzo and
the others who have contributed to this control.
While playing with the example code on the wiki, I found a bug in the
implementation such that, when switching between a multichoice and
single choice list, it would no longer autocomplete, because the
"fetchCol" was left set to a non-existent column in the dropdown.
I also found that, unlike the firefox address bar behavior, the dropdown
popped down as soon as you clicked in the text box, and didn't go away
when the textctrl is empty. Finally, unlike the address bar, there was
no option to automatically hide the dropdown if the text entered did not
match any choice.
These were relatively easy things to fix, so I have taken the liberty
of modifying the wiki code to handle these cases. I've also added
a link to this page under the Wiki's wxPython Cookbook/RecipesControls
section, as I couldn't find a link to it anywhere else from the main
page.
Another pair of enhancements would be to allow you to specify your
own "match" function, so that you could do fancy matching, the way
the address bar does, skipping boilerplate like http:, www, etc,
and an optional callback on each change to the text as typed, so
that you could set the control up to autogenerate a new choice list
based on what was typed so far as you typed, the way that the Firefox
address bar does-- this should be possible, and would be a wicked
cool demo too!
(I will think about doing these things if I ever find the time...)
But my real question is: Can this control be added to the lib
section of the distribution? It seems as useful as many other
contributed controls (mine included)... Robin, what say you?
/Will Sadkin
Author, lib.masked