Search code examples
comboboxwxpythongetselection

GetSelection ComboBox


I can't figure out what else I need for the combobox to select from my list as I type. Eventually I'm going to add SetInsertionPoint. But for now, my item selected is allways -1

self.filter = wx.ComboBox(self, wx.ID_ANY, choices = '', style=wx.CB_DROPDOWN)

def OnTextChanged(self, event):
    sel = self.filter.GetSelection()
    print 'OnItemSelected %s' % sel

Solution

  • This other SO answer has a custom control that might work for you:

    You may also get ideas from this wxPython wiki article

    I also noticed that the masked combo box may have this feature itself, according to the docs: http://www.wxpython.org/docs/api/wx.lib.masked.combobox-module.html which says the following

    BaseMaskedComboBox - Base class for generic masked edit comboboxes; allows auto-complete of values.