commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9041 - in trunk/gnue-forms/src/uidrivers/curses: . widgets


From: johannes
Subject: [gnue] r9041 - in trunk/gnue-forms/src/uidrivers/curses: . widgets
Date: Tue, 14 Nov 2006 07:59:13 -0600 (CST)

Author: johannes
Date: 2006-11-14 07:59:12 -0600 (Tue, 14 Nov 2006)
New Revision: 9041

Modified:
   trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
Log:
Start Pep8-ification of entry


Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2006-11-14 13:24:06 UTC 
(rev 9040)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2006-11-14 13:59:12 UTC 
(rev 9041)
@@ -256,8 +256,10 @@
             screen.move(1, 2)
 
         if kind == 'Question':
-            validKeys = {ord(yes[0]): True,
-                         ord(no[0]): False}
+            validKeys = {ord(yes[0].upper()): True,
+                         ord(yes[0].lower()): True,
+                         ord(no[0].upper()): False,
+                         ord(no[0].lower()): False}
         else:
             validKeys = {10: True}
 

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py      2006-11-14 
13:24:06 UTC (rev 9040)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py      2006-11-14 
13:59:12 UTC (rev 9041)
@@ -29,411 +29,415 @@
 # Entry class
 # =============================================================================
 
-class UIEntry (UIHelper):
+class UIEntry(UIHelper):
 
-  # ---------------------------------------------------------------------------
-  # Initialization
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Initialization
+    # -------------------------------------------------------------------------
 
-  def __init__ (self, event):
+    def __init__(self, event):
 
-    UIHelper.__init__ (self, event)
+        UIHelper.__init__(self, event)
 
-    self.__style = event.object.style
-    if self.__style in ['default', 'password', 'label', 'dropdown', 'listbox']:
-      self.__length = event.object ['Char:width']
-    else:
-      self.__length = None
+        self.__style = event.object.style
+        if self.__style in ['default', 'password', 'label', 'dropdown',
+                'listbox']:
+            self.__length = event.object['Char:width']
+        else:
+            self.__length = None
 
-    self.__height    = event.object ['Char:height']
-    self.__value     = {}
-    self.__offset    = {}
-    self.__selection = {}
-    self.__enabled   = {}
-    self.__voffset   = {}
+        self.__height    = event.object['Char:height']
+        self.__value     = {}
+        self.__offset    = {}
+        self.__selection = {}
+        self.__enabled   = {}
+        self.__voffset   = {}
 
-    self.__isMultiline = (self.__style in ['default', 'password'] and \
-                          self.__height > 1)
+        self.__isMultiline = (self.__style in ['default', 'password'] and \
+                              self.__height > 1)
 
-    self.__focusIndex = None
+        self.__focusIndex = None
 
-    self.__cursor = (0, 0)
+        self.__cursor = (0, 0)
 
-    # additional indices for listboxes
-    self.__index  = {}
-    self.__pindex = {}
-    self.__oldCursor = 1
+        # additional indices for listboxes
+        self.__index  = {}
+        self.__pindex = {}
+        self.__oldCursor = 1
 
-    if self.__style == 'dropdown':
-      self.__allowedValues = event.object._field._allowedValues
+        if self.__style == 'dropdown':
+            self.__allowedValues = event.object._field._allowedValues
 
-    elif self.__style == 'listbox':
-      self.__data = event.object._field._allowedValues.values ()
-      self.__data.sort ()
+        elif self.__style == 'listbox':
+            self.__data = event.object._field._allowedValues.values()
+            self.__data.sort()
 
-    if self.__style == 'checkbox':
-      self.__setCursor (1, 0)
+        if self.__style == 'checkbox':
+            self.__setCursor(1, 0)
 
-  # ---------------------------------------------------------------------------
-  # Initialization per row
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Initialization per row
+    # -------------------------------------------------------------------------
 
-  def _init (self, index):
+    def _init(self, index):
 
-    self.__value [index] = None
-    self.__selection [index] = None
-    self.__enabled [index] = True
-    self.__offset [index]  = 0
-    self.__voffset [index] = 0
-    self.__index [index]   = 0
-    self.__pindex [index]  = 1
+        self.__value[index] = None
+        self.__selection[index] = None
+        self.__enabled[index] = True
+        self.__offset[index]  = 0
+        self.__voffset[index] = 0
+        self.__index[index]   = 0
+        self.__pindex[index]  = 1
 
-  # ---------------------------------------------------------------------------
-  # Enable/disable this entry
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Enable/disable this entry
+    # -------------------------------------------------------------------------
 
-  def _ui_enable_(self, index):
-    self.__enabled[index] = True
-    self.__repaint(index)
- 
-  # ---------------------------------------------------------------------------
+    def _ui_enable_(self, index):
+        self.__enabled[index] = True
+        self.__repaint(index)
 
-  def _ui_disable_(self, index):
-    self.__enabled[index] = False
-    self.__repaint(index)
- 
-  # ---------------------------------------------------------------------------
-  # Focus has changed to this entry
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _getFocus (self, index):
+    def _ui_disable_(self, index):
+        self.__enabled[index] = False
+        self.__repaint(index)
 
-    self.__focusIndex = index
+    # -------------------------------------------------------------------------
+    # Focus has changed to this entry
+    # -------------------------------------------------------------------------
 
-    self.__offset [index]  = 0
-    self.__voffset [index] = 0
-    self.__index [index]   = 0
-    self.__pindex [index]  = 1
+    def _getFocus(self, index):
 
-    if self.__style == 'listbox':
-      self.__oldCursor = curses.curs_set (0)
+        self.__focusIndex = index
 
-    self.__updateCursorPosition ()
+        self.__offset[index]  = 0
+        self.__voffset[index] = 0
+        self.__index[index]   = 0
+        self.__pindex[index]  = 1
 
-    self.__repaint (index)
+        if self.__style == 'listbox':
+            self.__oldCursor = curses.curs_set(0)
 
-  # ---------------------------------------------------------------------------
-  # Focus has changed away from this entry
-  # ---------------------------------------------------------------------------
+        self.__updateCursorPosition()
 
-  def _lose_focus (self, index):
+        self.__repaint(index)
 
-    if self.__style == 'listbox':
-      curses.curs_set (self.__oldCursor)
+    # -------------------------------------------------------------------------
+    # Focus has changed away from this entry
+    # -------------------------------------------------------------------------
 
-    self.__focusIndex = None
-    self.__selection[index] = None
+    def _lose_focus(self, index):
 
-    self.__repaint (index)
+        if self.__style == 'listbox':
+            curses.curs_set(self.__oldCursor)
 
-  # ---------------------------------------------------------------------------
-  # Set value for entry
-  # ---------------------------------------------------------------------------
+        self.__focusIndex = None
+        self.__selection[index] = None
 
-  def _ui_set_value_ (self, index, value):
+        self.__repaint(index)
 
-    if self.__style == 'listbox' and value in self.__data:
-      if self.__value [index] <> value:
-        self.__index [index]  = self.__data.index (value)
-        self.__pindex [index] = 1
-        self.__offset [index] = self.__index [index]
+    # -------------------------------------------------------------------------
+    # Set value for entry
+    # -------------------------------------------------------------------------
 
-    self.__value [index]   = value
-    self.__repaint (index)
+    def _ui_set_value_(self, index, value):
 
-  # ---------------------------------------------------------------------------
-  # Set cursor position
-  # ---------------------------------------------------------------------------
+        if self.__style == 'listbox' and value in self.__data:
+            if self.__value[index] <> value:
+                self.__index[index]  = self.__data.index(value)
+                self.__pindex[index] = 1
+                self.__offset[index] = self.__index[index]
 
-  def _ui_set_cursor_position_ (self, index, position):
+        self.__value[index]   = value
+        self.__repaint(index)
 
-    assert gDebug (2, "----- new position: %s" % position)
-    assert gDebug (2, "      Value       : %r" % self.__value [index])
-    assert gDebug (2, "      Curr.Offset : %s/%s" % (self.__offset [index],
-      self.__voffset [index]))
+    # -------------------------------------------------------------------------
+    # Set cursor position
+    # -------------------------------------------------------------------------
 
-    if self.__style in ['checkbox', 'listbox']:
-      return
+    def _ui_set_cursor_position_(self, index, position):
 
-    if self.__isMultiline:
-      if position == 0 or self.__value [index] is None:
-        self.__offset [index]  = 0
-        self.__voffset [index] = 0
-        self.__repaint (index)
-        self.__setCursor (0, 0)
-        return
+        assert gDebug(2, "----- new position: %s" % position)
+        assert gDebug(2, "      Value       : %r" % self.__value[index])
+        assert gDebug(2, "      Curr.Offset : %s/%s" % (self.__offset[index],
+          self.__voffset[index]))
 
-      # Grab the text portion, which is everything up to position. If the last
-      # character is a newline, we can remove this, since it would result in a
-      # wrong vertical offset
-      value = self.__value [index][:position+1]
-      vcorr = [0, 1][value [-1] == '\n']
+        if self.__style in ['checkbox', 'listbox']:
+            return
 
-      assert gDebug (2, "      Cut-Part    : %r" % value)
-      assert gDebug (2, "      Vert.Correct: %s" % vcorr)
+        if self.__isMultiline:
+            if position == 0 or self.__value[index] is None:
+                self.__offset[index]  = 0
+                self.__voffset[index] = 0
+                self.__repaint(index)
+                self.__setCursor(0, 0)
+                return
 
-      # Get the vertical cursor-position and offset
-      cpVertical  = value.count ('\n') - self.__voffset [index] - vcorr
-      needRepaint = False
-      
-      if cpVertical < 0:
-        # the position is not visible right now, so we need to scroll up (which
-        # means changing the voffset). We set the cursor-position to line 0.
-        self.__voffset [index] += cpVertical
-        cpVertical  = 1
-        needRepaint = True
+            # Grab the text portion, which is everything up to position. If 
the last
+            # character is a newline, we can remove this, since it would 
result in a
+            # wrong vertical offset
+            value = self.__value[index][:position+1]
+            vcorr = [0, 1][value[-1] == '\n']
 
-      elif cpVertical >= self.__height:
-        # the position is not visible right now, so we need to scroll down
-        # (which means changing the voffset).
-        self.__voffset [index] = value.count ('\n') - self.__height + 1 - vcorr
-        cpVertical  = self.__height                      # Pos. are Zero-based
-        needRepaint = True
+            assert gDebug(2, "      Cut-Part    : %r" % value)
+            assert gDebug(2, "      Vert.Correct: %s" % vcorr)
 
-      # Now, after having a valid row, we need to determine the horizontal
-      # offset based on the last line holding our requested position.
-      currentLine = value.splitlines () [-1]
-      cpHorizontal = len (currentLine) - self.__offset [index] - 1
+            # Get the vertical cursor-position and offset
+            cpVertical  = value.count('\n') - self.__voffset[index] - vcorr
+            needRepaint = False
 
-      if cpHorizontal < 0:
-        # Beyond left margin, so scroll to the left
-        self.__offset [index] += cpHorizontal
-        cpHorizontal = 0
-        needRepaint  = True
+            if cpVertical < 0:
+                # the position is not visible right now, so we need to scroll
+                # up (which means changing the voffset). We set the
+                # cursor-position to line 0.
+                self.__voffset[index] += cpVertical
+                cpVertical  = 1
+                needRepaint = True
 
-      elif cpHorizontal > self.__length:
-        self.__offset [index] = len (currentLine) - self.__length
-        cpHorizontal = self.__length
-        needRepaint  = True
+            elif cpVertical >= self.__height:
+                # the position is not visible right now, so we need to scroll
+                # down (which means changing the voffset).
+                self.__voffset[index] = value.count('\n') - \
+                        self.__height + 1 - vcorr
+                cpVertical  = self.__height            # Pos. are Zero-based
+                needRepaint = True
 
-      if needRepaint:
-        self.__repaint (index)
+            # Now, after having a valid row, we need to determine the 
horizontal
+            # offset based on the last line holding our requested position.
+            currentLine = value.splitlines()[-1]
+            cpHorizontal = len(currentLine) - self.__offset[index] - 1
 
-      cpHorizontal = min (cpHorizontal, self.__length)
-      cpHorizontal = max (cpHorizontal, 0)
-      cpVertical   = min (cpVertical, self.__height - 1)
-      cpVertical   = max (cpVertical, 0)
+            if cpHorizontal < 0:
+                # Beyond left margin, so scroll to the left
+                self.__offset[index] += cpHorizontal
+                cpHorizontal = 0
+                needRepaint  = True
 
-      assert gDebug (2, "H/V: %s/%s - Offsets %s/%s" % (cpHorizontal, 
cpVertical,
-        self.__offset [index], self.__voffset [index]))
+            elif cpHorizontal > self.__length:
+                self.__offset[index] = len(currentLine) - self.__length
+                cpHorizontal = self.__length
+                needRepaint  = True
 
-      self.__setCursor (cpHorizontal, cpVertical)
+            if needRepaint:
+                self.__repaint(index)
 
+            cpHorizontal = min(cpHorizontal, self.__length)
+            cpHorizontal = max(cpHorizontal, 0)
+            cpVertical   = min(cpVertical, self.__height - 1)
+            cpVertical   = max(cpVertical, 0)
 
-    else:
-      if self.__length:
-        npos = position - self.__offset [index]
-        if npos > self.__length:
-          self.__offset [index] = position - self.__length
-          npos = self.__length
-          self.__repaint (index)
+            assert gDebug(2, "H/V: %s/%s - Offsets %s/%s" % (cpHorizontal,
+                cpVertical, self.__offset[index], self.__voffset[index]))
 
-        elif npos < 0:
-          self.__offset [index] += npos
-          npos = 0
-          self.__repaint (index)
+            self.__setCursor(cpHorizontal, cpVertical)
 
-        position = npos
 
-      self.__setCursor (position, 0)
+        else:
+            if self.__length:
+                npos = position - self.__offset[index]
+                if npos > self.__length:
+                    self.__offset[index] = position - self.__length
+                    npos = self.__length
+                    self.__repaint(index)
 
+                elif npos < 0:
+                    self.__offset[index] += npos
+                    npos = 0
+                    self.__repaint(index)
 
-  # ---------------------------------------------------------------------------
-  # Set start and end of selection area
-  # ---------------------------------------------------------------------------
+                position = npos
 
-  def _ui_set_selected_area_ (self, index, selection1, selection2):
+            self.__setCursor(position, 0)
 
-    if selection1 == selection2:
-      self.__selection [index] = None
-    else:
-      self.__selection [index] = (selection1, selection2)
 
-    self.__repaint (index)
+    # -------------------------------------------------------------------------
+    # Set start and end of selection area
+    # -------------------------------------------------------------------------
 
-  # ---------------------------------------------------------------------------
-  # Clipboard and selection
-  # ---------------------------------------------------------------------------
+    def _ui_set_selected_area_(self, index, selection1, selection2):
 
-  def _ui_cut_(self, index):
+        if selection1 == selection2:
+            self.__selection[index] = None
+        else:
+            self.__selection[index] = (selection1, selection2)
+
+        self.__repaint(index)
+        gDebug(2, "Set-Selection: %s %s %s" % (index, selection1, selection2))
+
+    # -------------------------------------------------------------------------
+    # Clipboard and selection
+    # -------------------------------------------------------------------------
+
+    def _ui_cut_(self, index):
         pass
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _ui_copy_(self, index):
+    def _ui_copy_(self, index):
         pass
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _ui_paste_(self, index):
+    def _ui_paste_(self, index):
         pass
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def _ui_select_all_(self, index):
+    def _ui_select_all_(self, index):
         pass
 
-  # ---------------------------------------------------------------------------
-  # Update entry representation on screen
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Update entry representation on screen
+    # -------------------------------------------------------------------------
 
-  def __repaint (self, index):
+    def __repaint(self, index):
 
-    if self.__style == 'listbox':
-      # First draw the visible items of the listbox
-      offset = self.__offset [index]
-      lines  = self.__data [offset:offset + self.__height]
+        if self.__style == 'listbox':
+            # First draw the visible items of the listbox
+            offset = self.__offset[index]
+            lines  = self.__data[offset:offset + self.__height]
 
-      for (line, value) in enumerate (lines):
-        text = value.ljust (self.__length) [:self.__length]
-        attr = self.__getAttr (index)
+            for (line, value) in enumerate(lines):
+                text = value.ljust(self.__length)[:self.__length]
+                attr = self.__getAttr(index)
 
-        # Note: this is not safe if there's a gap !
-        self._setText (index + line, text, attr, self.__selection [index])
+                # Note: this is not safe if there's a gap !
+                self._setText(index + line, text, attr, 
self.__selection[index])
 
-      self._parent.move (self._x, self._y + self.__pindex [index] - 1)
+            self._parent.move(self._x, self._y + self.__pindex[index] - 1)
 
-    elif self.__isMultiline:
-      # Create all visible, empty lines
-      data    = [''.ljust (self.__length)] * self.__height
-      hOffset = self.__offset [index]
-      vOffset = self.__voffset [index]
+        elif self.__isMultiline:
+            # Create all visible, empty lines
+            data    = [''.ljust(self.__length)] * self.__height
+            hOffset = self.__offset[index]
+            vOffset = self.__voffset[index]
 
-      # Overwrite these empty lines with the data as stated by v/h-Offset
-      if self.__value [index]:
-        add = self.__value [index].splitlines () 
[vOffset:vOffset+self.__height]
-        for (ix, text) in enumerate (add):
-          text = text [hOffset:hOffset + self.__length]
-          data [ix] = text.ljust (self.__length) [:self.__length]
+            # Overwrite these empty lines with the data as stated by v/h-Offset
+            if self.__value[index]:
+                add = 
self.__value[index].splitlines()[vOffset:vOffset+self.__height]
+                for (ix, text) in enumerate(add):
+                    text = text[hOffset:hOffset + self.__length]
+                    data[ix] = text.ljust(self.__length)[:self.__length]
 
-      attr = self.__getAttr (index)
+            attr = self.__getAttr(index)
 
-      # And write everything to screen
-      for (ix, text) in enumerate (data):
-        self._setText (index + ix, text, attr, self.__selection [index])
+            # And write everything to screen
+            for (ix, text) in enumerate(data):
+                self._setText(index + ix, text, attr, self.__selection[index])
 
-    else:
-      value  = self.__value [index]
-      offset = self.__offset [index]
+        else:
+            value  = self.__value[index]
+            offset = self.__offset[index]
 
-      if self.__style in ['default', 'label', 'dropdown']:
-        text = value or ''
-        text = text [offset:offset + self.__length]
-        text += ' ' * (self.__length - len (text))
+            if self.__style in['default', 'label', 'dropdown']:
+                text = value or ''
+                text = text[offset:offset + self.__length]
+                text += ' ' * (self.__length - len(text))
 
-      elif self.__style == 'password':
-        text = '*' * len (value or '')
-        text = text [offset:offset + self.__length]
-        text += ' ' * (self.__length - len (text))
+            elif self.__style == 'password':
+                text = '*' * len(value or '')
+                text = text[offset:offset + self.__length]
+                text += ' ' * (self.__length - len(text))
 
-      elif self.__style == 'checkbox':
-        if self.__value[index] is None:
-            text = '[-]'
-        elif self.__value[index]:
-            text = '[X]'
-        else:
-            text = '[ ]'
+            elif self.__style == 'checkbox':
+                if self.__value[index] is None:
+                    text = '[-]'
+                elif self.__value[index]:
+                    text = '[X]'
+                else:
+                    text = '[ ]'
 
-      attr = self.__getAttr (index)
-      self._setText (index, text, attr, self.__selection [index])
+            attr = self.__getAttr(index)
+            self._setText(index, text, attr, self.__selection[index])
 
 
-  # ---------------------------------------------------------------------------
-  # Get the current screen attributes to be used
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Get the current screen attributes to be used
+    # -------------------------------------------------------------------------
 
-  def __getAttr (self, index):
+    def __getAttr(self, index):
 
-    if self.__style == 'label':
-      attr = self._uiDriver.attr['background']
-    elif not self.__enabled[index]:
-      attr = self._uiDriver.attr['disabled']
-    elif index == self.__focusIndex:
-      attr = self._uiDriver.attr['focusentry']
-    else:
-      attr = self._uiDriver.attr['entry']
+        if self.__style == 'label':
+            attr = self._uiDriver.attr['background']
+        elif not self.__enabled[index]:
+            attr = self._uiDriver.attr['disabled']
+        elif index == self.__focusIndex:
+            attr = self._uiDriver.attr['focusentry']
+        else:
+            attr = self._uiDriver.attr['entry']
 
-    return attr
+        return attr
 
 
-  # ---------------------------------------------------------------------------
-  # handle keypress
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # handle keypress
+    # -------------------------------------------------------------------------
 
-  def _keypress (self, key):
+    def _keypress(self, key):
 
-    if self.__style == 'dropdown' and key == chr (self._uiDriver.lookupKey):
-      res = self._uiDriver.getOption (u_("Select option"), 
self.__allowedValues)
-      if res is not None:
-        self._request ('REPLACEVALUE', text = res)
-    else:
-      UIHelper._keypress (self, key)
+        if self.__style == 'dropdown' and key == chr(self._uiDriver.lookupKey):
+            res = self._uiDriver.getOption(u_("Select option"), 
self.__allowedValues)
+            if res is not None:
+                self._request('REPLACEVALUE', text = res)
+        else:
+            UIHelper._keypress(self, key)
 
 
-  # ---------------------------------------------------------------------------
-  # handle function keypress
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # handle function keypress
+    # -------------------------------------------------------------------------
 
-  def _fkeypress (self, key, shift, ctrl, meta):
+    def _fkeypress(self, key, shift, ctrl, meta):
 
-    if self.__style == 'listbox' and key in [curses.KEY_DOWN, curses.KEY_UP]:
-      self.__move ([1, -1][key == curses.KEY_UP])
-    else:
-      UIHelper._fkeypress (self, key, shift, ctrl, meta)
+        if self.__style == 'listbox' and key in[curses.KEY_DOWN, 
curses.KEY_UP]:
+            self.__move([1, -1][key == curses.KEY_UP])
+        else:
+            UIHelper._fkeypress(self, key, shift, ctrl, meta)
 
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __move (self, direction):
+    def __move(self, direction):
 
-    index = self.__focusIndex
-    self.__pindex [index] += direction
-    self.__index [index] += direction
+        index = self.__focusIndex
+        self.__pindex[index] += direction
+        self.__index[index] += direction
 
-    if self.__pindex [index] > self.__height:
-      if self.__index [index] < len (self.__data):
-        self.__offset [index] += direction
+        if self.__pindex[index] > self.__height:
+            if self.__index[index] < len(self.__data):
+                self.__offset[index] += direction
 
-    elif self.__pindex [index] < 1:
-      self.__offset [index] = max (0, self.__offset [index] - 1)
+        elif self.__pindex[index] < 1:
+            self.__offset[index] = max(0, self.__offset[index] - 1)
 
-    self.__index [index] = max (0, self.__index [index])
-    self.__index [index] = min (len (self.__data) - 1, self.__index [index])
+        self.__index[index] = max(0, self.__index[index])
+        self.__index[index] = min(len(self.__data) - 1, self.__index[index])
 
-    self.__pindex [index] = max (1, self.__pindex [index])
-    self.__pindex [index] = min (self.__pindex [index], self.__height)
+        self.__pindex[index] = max(1, self.__pindex[index])
+        self.__pindex[index] = min(self.__pindex[index], self.__height)
 
-    self.__value [index] = self.__data [self.__index [index]]
-    self._request ('REPLACEVALUE', text = self.__data [self.__index [index]])
+        self.__value[index] = self.__data[self.__index[index]]
+        self._request('REPLACEVALUE', text = self.__data[self.__index[index]])
 
-  # ---------------------------------------------------------------------------
-  # Set cursor position for widget
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Set cursor position for widget
+    # -------------------------------------------------------------------------
 
-  def __setCursor (self, x, y):
+    def __setCursor(self, x, y):
 
-    self.__cursor = (x, y)
-    self.__updateCursorPosition ()
+        self.__cursor = (x, y)
+        self.__updateCursorPosition()
 
-  # ---------------------------------------------------------------------------
-  # Update cursor position
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Update cursor position
+    # -------------------------------------------------------------------------
 
-  def __updateCursorPosition (self):
+    def __updateCursorPosition(self):
 
-    if self.__focusIndex is not None:
-      (x, y) = self.__cursor
-      self._parent.move (self._x + x, self._y + self.__focusIndex + y)
+        if self.__focusIndex is not None:
+            (x, y) = self.__cursor
+            self._parent.move(self._x + x, self._y + self.__focusIndex + y)
 
 # =============================================================================
 # Configuration data





reply via email to

[Prev in Thread] Current Thread [Next in Thread]