controls/TextCtrlAutoComplete.py
changeset 1735 c02818d7e29f
parent 1733 dea107dce0c4
child 1736 7e61baa047f0
--- a/controls/TextCtrlAutoComplete.py	Mon Aug 14 22:23:17 2017 +0300
+++ b/controls/TextCtrlAutoComplete.py	Mon Aug 14 22:30:41 2017 +0300
@@ -35,28 +35,28 @@
     LISTBOX_INTERVAL_HEIGHT = 6
 
 class PopupWithListbox(wx.PopupWindow):
-    
+
     def __init__(self, parent, choices=[]):
         wx.PopupWindow.__init__(self, parent, wx.BORDER_SIMPLE)
-        
+
         self.ListBox = wx.ListBox(self, -1, style=wx.LB_HSCROLL|wx.LB_SINGLE|wx.LB_SORT)
-        
+
         self.SetChoices(choices)
-        
+
         self.ListBox.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
         self.ListBox.Bind(wx.EVT_MOTION, self.OnMotion)
-    
+
     def SetChoices(self, choices):
         max_text_width = 0
         max_text_height = 0
-        
+
         self.ListBox.Clear()
         for choice in choices:
             self.ListBox.Append(choice)
             w, h = self.ListBox.GetTextExtent(choice)
             max_text_width = max(max_text_width, w)
             max_text_height = max(max_text_height, h)
-        
+
         itemcount = min(len(choices), MAX_ITEM_SHOWN)
         width = self.Parent.GetSize()[0]
         height = max_text_height * itemcount + \
@@ -69,7 +69,7 @@
             size.width -= 2
         self.ListBox.SetSize(size)
         self.SetClientSize(size)
-    
+
     def MoveSelection(self, direction):
         selected = self.ListBox.GetSelection()
         if selected == wx.NOT_FOUND:
@@ -82,10 +82,10 @@
         if selected == self.ListBox.GetCount():
             selected = wx.NOT_FOUND
         self.ListBox.SetSelection(selected)
-    
+
     def GetSelection(self):
         return self.ListBox.GetStringSelection()
-    
+
     def OnLeftDown(self, event):
         selected = self.ListBox.HitTest(wx.Point(event.GetX(), event.GetY()))
         parent_size = self.Parent.GetSize()
@@ -99,12 +99,12 @@
         else:
             wx.CallAfter(self.Parent.DismissListBox)
         event.Skip()
-    
+
     def OnMotion(self, event):
         self.ListBox.SetSelection(
             self.ListBox.HitTest(wx.Point(event.GetX(), event.GetY())))
         event.Skip()
-    
+
 class TextCtrlAutoComplete(wx.TextCtrl):
 
     def __init__ (self, parent, choices=None, dropDownClick=True,
@@ -118,17 +118,17 @@
         therest['style'] = wx.TE_PROCESS_ENTER | therest.get('style', 0)
 
         wx.TextCtrl.__init__(self, parent, **therest)
-        
+
         # Some variables
         self._dropDownClick = dropDownClick
         self._lastinsertionpoint = None
         self._hasfocus = False
-        
+
         self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
         self.element_path = element_path
-        
+
         self.listbox = None
-        
+
         self.SetChoices(choices)
 
         #gp = self
@@ -201,14 +201,14 @@
         self.DismissListBox()
         self._hasfocus = False
         event.Skip()
-    
+
     def SetChoices(self, choices):
         self._choices = choices
         self.RefreshListBoxChoices()
-        
+
     def GetChoices(self):
         return self._choices
-    
+
     def SetValueFromSelected(self, selected):
         """
         Sets the wx.TextCtrl value from the selected wx.ListCtrl item.
@@ -217,7 +217,7 @@
         if selected != "":
             self.SetValue(selected)
         self.DismissListBox()
-    
+
     def RefreshListBoxChoices(self):
         if self.listbox is not None:
             text = self.GetValue()
@@ -227,7 +227,7 @@
     def PopupListBox(self):
         if self.listbox is None:
             self.listbox = PopupWithListbox(self)
-            
+
             # Show the popup right below or above the button
             # depending on available screen space...
             pos = self.ClientToScreen((0, 0))
@@ -236,9 +236,9 @@
                 pos.x -= 2
                 pos.y -= 2
             self.listbox.Position(pos, (0, sz[1]))
-            
+
             self.RefreshListBoxChoices()
-            
+
             self.listbox.Show()
 
     def DismissListBox(self):