[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9052 - trunk/gnue-forms/src/uidrivers/curses/widgets
From: |
johannes |
Subject: |
[gnue] r9052 - trunk/gnue-forms/src/uidrivers/curses/widgets |
Date: |
Mon, 20 Nov 2006 01:37:10 -0600 (CST) |
Author: johannes
Date: 2006-11-20 01:37:09 -0600 (Mon, 20 Nov 2006)
New Revision: 9052
Modified:
trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
trunk/gnue-forms/src/uidrivers/curses/widgets/label.py
Log:
Pep8-ification
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-11-20
01:06:21 UTC (rev 9051)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/_base.py 2006-11-20
07:37:09 UTC (rev 9052)
@@ -60,7 +60,7 @@
def _ui_set_focus_(self, index):
self._uiDriver._focus_widget = self
- self._getFocus (index)
+ self._get_focus(index)
# -------------------------------------------------------------------------
@@ -78,15 +78,13 @@
# Set text for widget
# -------------------------------------------------------------------------
- def _setText (self, index, text, attr, selection = None):
+ def _set_text(self, index, text, attr, selection = None):
- gDebug(2, "TEXT=%s" % repr(text))
- value = text
if selection:
(s1, s2) = selection
- self._parent.write (self._x, self._y + index, value[:s1], attr)
- self._parent.write (self._x + s1, self._y + index, value[s1:s2],
+ self._parent.write(self._x, self._y + index, text[:s1], attr)
+ self._parent.write(self._x + s1, self._y + index, text[s1:s2],
attr + curses.A_STANDOUT)
- self._parent.write (self._x + s2, self._y + index, value[s2:],
attr)
+ self._parent.write(self._x + s2, self._y + index, text[s2:], attr)
else:
- self._parent.write (self._x, self._y + index, value, attr)
+ self._parent.write(self._x, self._y + index, text, attr)
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/box.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/box.py 2006-11-20
01:06:21 UTC (rev 9051)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/box.py 2006-11-20
07:37:09 UTC (rev 9052)
@@ -25,33 +25,36 @@
from _base import UIHelper
+__all__ = ['UIBox']
+
# =============================================================================
# Box class
# =============================================================================
-class UIBox (UIHelper):
+class UIBox(UIHelper):
- def _init (self, index):
+ def _init(self, index):
- attr = self._uiDriver.attr ['background']
+ attr = self._uiDriver.attr['background']
- w = self._gfObject ['Char:width']
- h = self._gfObject ['Char:height']
+ w = self._gfObject['Char:width']
+ h = self._gfObject['Char:height']
- for pos in range (self._x+1, self._x+w-1):
- self._parent.putchar (pos, self._y , curses.ACS_HLINE, attr)
- self._parent.putchar (pos, self._y+h-1, curses.ACS_HLINE, attr)
+ for pos in range(self._x+1, self._x+w-1):
+ self._parent.putchar(pos, self._y , curses.ACS_HLINE, attr)
+ self._parent.putchar(pos, self._y+h-1, curses.ACS_HLINE, attr)
- for line in range (self._y+1, self._y+h-1):
- self._parent.putchar (self._x , line, curses.ACS_VLINE, attr)
- self._parent.putchar (self._x+w-1, line, curses.ACS_VLINE, attr)
+ for line in range(self._y+1, self._y+h-1):
+ self._parent.putchar(self._x , line, curses.ACS_VLINE, attr)
+ self._parent.putchar(self._x+w-1, line, curses.ACS_VLINE, attr)
- self._parent.putchar (self._x , self._y , curses.ACS_ULCORNER, attr)
- self._parent.putchar (self._x+w-1, self._y , curses.ACS_URCORNER, attr)
- self._parent.putchar (self._x , self._y+h-1, curses.ACS_LLCORNER, attr)
- self._parent.putchar (self._x+w-1, self._y+h-1, curses.ACS_LRCORNER, attr)
+ self._parent.putchar(self._x, self._y, curses.ACS_ULCORNER, attr)
+ self._parent.putchar(self._x+w-1, self._y, curses.ACS_URCORNER, attr)
+ self._parent.putchar(self._x, self._y+h-1, curses.ACS_LLCORNER, attr)
+ self._parent.putchar(self._x+w-1, self._y+h-1, curses.ACS_LRCORNER,
+ attr)
- self._parent.write (self._x+2, self._y, self._gfObject.label, attr)
+ self._parent.write(self._x+2, self._y, self._gfObject.label, attr)
# =============================================================================
# Configuration data
@@ -61,4 +64,4 @@
'baseClass' : UIBox,
'provides' : 'GFBox',
'container' : 0,
- }
+}
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/button.py 2006-11-20
01:06:21 UTC (rev 9051)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/button.py 2006-11-20
07:37:09 UTC (rev 9052)
@@ -25,96 +25,101 @@
from _base import UIHelper
+__all__ = ['UIButton']
+
# =============================================================================
# Button class
# =============================================================================
class UIButton (UIHelper):
- # ---------------------------------------------------------------------------
- # Initialization
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Initialization
+ # -------------------------------------------------------------------------
- def __init__ (self, event):
+ def __init__(self, event):
- UIHelper.__init__ (self, event)
+ UIHelper.__init__(self, event)
- # Determine button text
- maxlen = event.object ['Char:width'] - 2
- label = event.object.label [:maxlen] # cut if too long
- label = ' ' * ((maxlen - len (label)) / 2) + label # expand if too short
- label = label + ' ' * (maxlen - len (label))
+ # Determine button text
+ maxlen = event.object['Char:width'] - 2
+ label = event.object.label[:maxlen] # cut if too long
+ label = ' ' * ((maxlen - len(label)) / 2) + label # expand if too
short
+ label = label + ' ' * (maxlen - len(label))
- self.__text = '[' + label + ']'
+ self.__text = '[' + label + ']'
- self.__enabled = {}
+ self.__enabled = {}
- # ---------------------------------------------------------------------------
- # Initialization per row
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Initialization per row
+ # -------------------------------------------------------------------------
- def _init (self, index):
+ def _init(self, index):
- self.__enabled [index] = True
- self.__repaint (index, False)
+ self.__enabled[index] = True
+ self.__repaint(index, False)
- # ---------------------------------------------------------------------------
- # Enable/disable this button
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Enable/disable this button
+ # -------------------------------------------------------------------------
- def _ui_enable_(self, index):
- self.__enabled[index] = True
- self.__repaint(index, False)
-
- # ---------------------------------------------------------------------------
+ def _ui_enable_(self, index):
+ self.__enabled[index] = True
+ self.__repaint(index, False)
- def _ui_disable_(self, index):
- self.__enabled[index] = False
- self.__repaint(index, False)
-
- # ---------------------------------------------------------------------------
- # Focus has changed to this button
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
- def _getFocus (self, index):
+ def _ui_disable_(self, index):
+ self.__enabled[index] = False
+ self.__repaint(index, False)
- self.__repaint (index, True)
+ # -------------------------------------------------------------------------
+ # Focus has changed to this button
+ # -------------------------------------------------------------------------
- # ---------------------------------------------------------------------------
- # Focus has changed away from this button
- # ---------------------------------------------------------------------------
+ def _get_focus(self, index):
+ self.__repaint(index, True)
- def _lose_focus (self, index):
+ # -------------------------------------------------------------------------
+ # Focus has changed away from this button
+ # -------------------------------------------------------------------------
- self.__repaint (index, False)
+ def _lose_focus(self, index):
- # ---------------------------------------------------------------------------
- # Update button representation on screen
- # ---------------------------------------------------------------------------
+ self.__repaint(index, False)
- def __repaint (self, index, focused):
+ # -------------------------------------------------------------------------
+ # Update button representation on screen
+ # -------------------------------------------------------------------------
- if focused:
- attr = self._uiDriver.attr ['focusentry']
- elif not self.__enabled [index]:
- attr = self._uiDriver.attr ['disabled']
- else:
- attr = self._uiDriver.attr ['entry']
+ def __repaint(self, index, focused):
- self._setText (index, self.__text, attr)
+ if focused:
+ attr = self._uiDriver.attr['focusentry']
+ elif not self.__enabled[index]:
+ attr = self._uiDriver.attr['disabled']
+ else:
+ attr = self._uiDriver.attr['entry']
- def _keypress(self, key):
- if key in [' ', '\n']:
- self._gfObject._event_fire()
- else:
- UIHelper._keypress(self, key)
+ self._set_text(index, self.__text, attr)
+ # -------------------------------------------------------------------------
+
+ def _keypress(self, key):
+
+ if key in [' ', '\n']:
+ self._gfObject._event_fire()
+ else:
+ UIHelper._keypress(self, key)
+
+
# =============================================================================
# Configuration data
# =============================================================================
configuration = {
- 'baseClass' : UIButton,
- 'provides' : 'GFButton',
- 'container' : 0,
- }
+ 'baseClass': UIButton,
+ 'provides' : 'GFButton',
+ 'container': 0,
+}
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-11-20
01:06:21 UTC (rev 9051)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2006-11-20
07:37:09 UTC (rev 9052)
@@ -107,7 +107,7 @@
# Focus has changed to this entry
# -------------------------------------------------------------------------
- def _getFocus(self, index):
+ def _get_focus(self, index):
self.__focusIndex = index
@@ -311,7 +311,7 @@
attr = self.__getAttr(index)
# Note: this is not safe if there's a gap !
- self._setText(index + line, text, attr,
self.__selection[index])
+ self._set_text(index+line, text, attr, self.__selection[index])
self._parent.move(self._x, self._y + self.__pindex[index] - 1)
@@ -333,7 +333,7 @@
# And write everything to screen
for (ix, text) in enumerate(data):
- self._setText(index + ix, text, attr, self.__selection[index])
+ self._set_text(index + ix, text, attr, self.__selection[index])
else:
value = self.__value[index]
@@ -362,7 +362,7 @@
gDebug(2, "STYLE==%s" % self.__style)
attr = self.__getAttr(index)
- self._setText(index, text, attr, self.__selection[index])
+ self._set_text(index, text, attr, self.__selection[index])
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/label.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/label.py 2006-11-20
01:06:21 UTC (rev 9051)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/label.py 2006-11-20
07:37:09 UTC (rev 9052)
@@ -21,20 +21,20 @@
#
# $Id$
-import curses
-
from _base import UIHelper
+__all__ = ['UILabel']
+
# =============================================================================
# Label class
# =============================================================================
-class UILabel (UIHelper):
+class UILabel(UIHelper):
- def _init (self, index):
+ def _init(self, index):
- self._setText (index, self._gfObject.text,
- self._uiDriver.attr ['background'])
+ self._set_text(index, self._gfObject.text,
+ self._uiDriver.attr['background'])
# =============================================================================
# Configuration data
@@ -44,4 +44,4 @@
'baseClass' : UILabel,
'provides' : 'GFLabel',
'container' : 0,
- }
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9052 - trunk/gnue-forms/src/uidrivers/curses/widgets,
johannes <=