1

I would like to implement auto-completion feature for wx.ComboBox widget. I do something like this in my init method:

self.languages = ['english', 'german']    
self.lexer = wx.ComboBox(self, -1, choices=self.languages, style=wx.CB_SORT)
self.Bind(wx.EVT_TEXT, self.on_dropdown_text_change, self.combo)

def on_dropdown_text_change(self, event):
    string = self.lexer.GetValue()
    items = []
    for item in self.languages:
        if item.lower().startswith(string.lower()):
            items.append(item)
    if items:
        self.lexer.SetItems(items)
        self.lexer.SetValue(items[0])
        self.lexer.SetTextSelection(len(string), -1)

So when user inputs something in ComboBox field I would like to highlight the part that was autocompleted. According to docs that should help me link to docs

I use wxPython 3.0 and get this error:

AttributeError: 'ComboBox' object has no attribute 'SetTextSelection'

Am I doing something wrong? Authors covered SetTextSelection method in tests, so, I guess, this method should be in place...

IgorekPotworek
  • 1,317
  • 13
  • 33
jsnjack
  • 2,630
  • 2
  • 21
  • 21
  • Have you tried ```self.lexer.SetSelection()```? – wnnmaw Jun 03 '14 at 18:45
  • SetSelection() is used for selection item from choices, not highlighting – jsnjack Jun 03 '14 at 18:58
  • The docs you point to claim they are both the same as [TextEntry.SetSelection()](http://wxpython.org/Phoenix/docs/html/TextEntry.html#TextEntry.SetSelection) – wnnmaw Jun 03 '14 at 19:08
  • Not really (although, docs seems to be a bit messy). It points that ComboBox.SetTextSelection() is the same as TextEntry.SetSelection(). ComboBox.SetSelection() has different purpose. – jsnjack Jun 03 '14 at 19:27

0 Answers0