[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9062 - in trunk/gnue-forms/src/uidrivers/curses: . widgets
From: |
johannes |
Subject: |
[gnue] r9062 - in trunk/gnue-forms/src/uidrivers/curses: . widgets |
Date: |
Fri, 24 Nov 2006 04:58:39 -0600 (CST) |
Author: johannes
Date: 2006-11-24 04:58:38 -0600 (Fri, 24 Nov 2006)
New Revision: 9062
Modified:
trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
Log:
Pep8-ification
Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2006-11-24 09:46:08 UTC
(rev 9061)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2006-11-24 10:58:38 UTC
(rev 9062)
@@ -274,7 +274,7 @@
break
if self.__current_form: # repaint status line of form
- self.__current_form.statusMessage(None)
+ self.__current_form.status_message(None)
return result
@@ -315,7 +315,7 @@
"""
if self.__current_form:
- (left, top, right, bottom) = self.__current_form.getCanvas()
+ (left, top, right, bottom) = self.__current_form.get_canvas()
else:
(right, bottom) = self.__screen.getmaxyx()
left = top = 0
@@ -326,6 +326,7 @@
return dialog.run()
finally:
+ # TODO: this should only refresh the current form (workspace)
self.__screen.refresh()
@@ -345,7 +346,7 @@
def _getInput(self, title, fields, cancel=True):
if self.__current_form:
- (left, top, right, bottom) = self.__current_form.getCanvas()
+ (left, top, right, bottom) = self.__current_form.get_canvas()
else:
(right, bottom) = self.__screen.getmaxyx()
left = top = 0
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2006-11-24
09:46:08 UTC (rev 9061)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2006-11-24
10:58:38 UTC (rev 9062)
@@ -22,234 +22,236 @@
# $Id$
import curses
-import string
from gnue.forms.input.GFKeyMapper import KeyMapper
from gnue.forms.uidrivers._base import UIdriver as BaseDriver
from gnue.forms.uidrivers._base.widgets._base import UIWidget
+__all__ = ['UIForm']
+
# =============================================================================
# Form class
# =============================================================================
-class UIForm (UIWidget):
+class UIForm(UIWidget):
- # ---------------------------------------------------------------------------
- # Initialization
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Initialization
+ # -------------------------------------------------------------------------
- def __init__ (self, event):
+ def __init__(self, event):
- UIWidget.__init__ (self, event)
+ UIWidget.__init__(self, event)
- self.__pages = []
- self.__currentPage = None
+ self.__pages = []
+ self.__currentPage = None
- # Status bar values
- self.__tip = ''
- self.__status = ''
- self.__insert = ''
- self.__curRec = 0
- self.__maxRec = 0
- self.__curPage = 0
- self.__maxPage = 0
+ # Status bar values
+ self.__tip = ''
+ self.__status = ''
+ self.__insert = ''
+ self.__curRec = 0
+ self.__maxRec = 0
+ self.__curPage = 0
+ self.__maxPage = 0
- # ---------------------------------------------------------------------------
- # Initialize form
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Initialize form
+ # -------------------------------------------------------------------------
- def create_widget (self, event, spacer):
+ def create_widget(self, event, spacer):
- (x, y) = event.interface.screen_size ()
- self.__window = curses.newpad (y, x)
- self.__window.keypad (1)
+ (x, y) = event.interface.screen_size()
+ self.__window = curses.newpad(y, x)
+ self.__window.keypad(1)
- self._ui_set_title_(event.object.title)
+ self._ui_set_title_(event.object.title)
- # ---------------------------------------------------------------------------
- # Set form title
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Set form title
+ # -------------------------------------------------------------------------
- def _ui_set_title_(self, title):
+ def _ui_set_title_(self, title):
- (y, x) = self.__window.getmaxyx ()
+ (y, x) = self.__window.getmaxyx()
- text = ' ' * ((x - len (title)) / 2) + title
+ text = ' ' * ((x - len(title)) / 2) + title
- self.__window.bkgdset (' ', self._uiDriver.attr ['title'])
- self.__window.addstr (0, 0, o(text))
- self.__window.clrtoeol ()
- self.__window.refresh (0, 0, 0, 0, 0, x)
+ self.__window.bkgdset(' ', self._uiDriver.attr ['title'])
+ self.__window.addstr(0, 0, o(text))
+ self.__window.clrtoeol()
+ self.__window.refresh(0, 0, 0, 0, 0, x)
- # ---------------------------------------------------------------------------
- # User feedback functions
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # User feedback functions
+ # -------------------------------------------------------------------------
- def _ui_begin_wait_(self):
- self.statusMessage(u_("processing..."))
+ def _ui_begin_wait_(self):
+ self.status_message(u_("processing..."))
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
- def _ui_end_wait_(self):
- self.statusMessage(None)
+ def _ui_end_wait_(self):
+ self.status_message(None)
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
- def _ui_beep_(self):
- curses.beep()
+ def _ui_beep_(self):
+ curses.beep()
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
- def _ui_update_status_(self, tip, status, insert, curRec, maxRec, curPage,
- maxPage):
+ def _ui_update_status_(self, tip, status, insert, curRec, maxRec, curPage,
+ maxPage):
- # Gets called with incomplete parameters, so we always have to remember the
- # old values for missing parameters
- if tip is not None: self.__tip = tip
- if status is not None: self.__status = status
- if insert is not None: self.__insert = insert
- if curRec is not None: self.__curRec = curRec
- if maxRec is not None: self.__maxRec = maxRec
- if curPage is not None: self.__curPage = curPage
- if maxPage is not None: self.__maxPage = maxPage
+ # Gets called with incomplete parameters, so we always have to remember
+ # the old values for missing parameters
+ if tip is not None: self.__tip = tip
+ if status is not None: self.__status = status
+ if insert is not None: self.__insert = insert
+ if curRec is not None: self.__curRec = curRec
+ if maxRec is not None: self.__maxRec = maxRec
+ if curPage is not None: self.__curPage = curPage
+ if maxPage is not None: self.__maxPage = maxPage
- self.__updateStatusBar ()
+ self.__update_status_bar()
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
- def _ui_show_message_(self, message, kind, title, cancel):
+ def _ui_show_message_(self, message, kind, title, cancel):
- return self._uiDriver.show_message(message, kind, cancel)
+ return self._uiDriver.show_message(message, kind, cancel)
- # ---------------------------------------------------------------------------
- # Print form screenshot
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Print form screenshot
+ # -------------------------------------------------------------------------
- def _ui_printout_(self, title, subtitle, user):
+ def _ui_printout_(self, title, subtitle, user):
- pass
+ pass
- # ---------------------------------------------------------------------------
- # Output a message on the status bar
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Output a message on the status bar
+ # -------------------------------------------------------------------------
- def statusMessage (self, message):
+ def status_message(self, message):
- if message:
- (y, x) = self.__window.getmaxyx ()
- self.__window.bkgdset (' ', self._uiDriver.attr ['status'])
- self.__window.addstr (y - 2, 0, o(message))
- self.__window.clrtoeol ()
- self.__window.refresh (y - 2, 0, y - 2, 0, y - 2, x)
- else:
- self.__updateStatusBar ()
+ if message:
+ (y, x) = self.__window.getmaxyx()
+ self.__window.bkgdset(' ', self._uiDriver.attr ['status'])
+ self.__window.addstr(y - 2, 0, o(message))
+ self.__window.clrtoeol()
+ self.__window.refresh(y - 2, 0, y - 2, 0, y - 2, x)
+ else:
+ self.__update_status_bar()
- # ---------------------------------------------------------------------------
- # Go to a specific page
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Go to a specific page
+ # -------------------------------------------------------------------------
- def _ui_goto_page_(self, page):
+ def _ui_goto_page_(self, page):
- self.__currentPage = page
- self.__updatePageList ()
+ self.__currentPage = page
+ self.__update_page_list()
- # ---------------------------------------------------------------------------
- # Add a page to the form
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Add a page to the form
+ # -------------------------------------------------------------------------
- def addPage (self, page, caption):
- self.__pages.append ((page, caption))
- if not self.__currentPage:
- self.__currentPage = page
- self.__updatePageList ()
+ def add_page(self, page, caption):
+ self.__pages.append((page, caption))
+ if not self.__currentPage:
+ self.__currentPage = page
+ self.__update_page_list()
- # ---------------------------------------------------------------------------
- # Update screen and wait for user input
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Update screen and wait for user input
+ # -------------------------------------------------------------------------
- def wait (self):
- return self.__currentPage.wait ()
+ def wait(self):
+ return self.__currentPage.wait()
- # ---------------------------------------------------------------------------
- # Get free area in the window
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Get free area in the window
+ # -------------------------------------------------------------------------
- def getCanvas (self):
+ def get_canvas(self):
- (y, x) = self.__window.getmaxyx ()
- return (0, 2, x, y - 2)
+ (y, x) = self.__window.getmaxyx()
+ return (0, 2, x, y - 2)
- # ---------------------------------------------------------------------------
- # Update page list
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Update page list
+ # -------------------------------------------------------------------------
- def __updatePageList (self):
+ def __update_page_list(self):
- self.__window.bkgdset (' ', self._uiDriver.attr ['page'])
- self.__window.move (1, 0)
+ self.__window.bkgdset(' ', self._uiDriver.attr ['page'])
+ self.__window.move(1, 0)
- for (page, caption) in self.__pages:
- if caption is None:
- caption = ' '
- if page == self.__currentPage:
- self.__window.addstr ('[' + o(caption) + ']',
- self._uiDriver.attr ['currentpage'])
- else:
- self.__window.addstr ('[' + o(caption) + ']')
- # self.__window.addstr (' ')
+ for (page, caption) in self.__pages:
+ if caption is None:
+ caption = ' '
+ if page == self.__currentPage:
+ self.__window.addstr('[' + o(caption) + ']',
+ self._uiDriver.attr ['currentpage'])
+ else:
+ self.__window.addstr('[' + o(caption) + ']')
+ # self.__window.addstr (' ')
- self.__window.clrtoeol ()
+ self.__window.clrtoeol()
- (y, x) = self.__window.getmaxyx ()
- self.__window.refresh (1, 0, 1, 0, 1, x)
+ (y, x) = self.__window.getmaxyx()
+ self.__window.refresh(1, 0, 1, 0, 1, x)
- # ---------------------------------------------------------------------------
- # Update status bar
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Update status bar
+ # -------------------------------------------------------------------------
- def __updateStatusBar (self):
+ def __update_status_bar(self):
- (y, x) = self.__window.getmaxyx ()
- self.__window.bkgdset (' ', self._uiDriver.attr ['status'])
+ (y, x) = self.__window.getmaxyx()
+ self.__window.bkgdset(' ', self._uiDriver.attr ['status'])
- tip = ('%-' + str (x - 25) + 's') % self.__tip
+ tip = ('%-' + str(x - 25) + 's') % self.__tip
- recstr = '%d/%d' % (self.__curRec, self.__maxRec)
- pagestr = '%d/%d' % (self.__curPage, self.__maxPage)
+ recstr = '%d/%d' % (self.__curRec, self.__maxRec)
+ pagestr = '%d/%d' % (self.__curPage, self.__maxPage)
- self.__window.addstr (y - 2, 0, '%s' % o(tip))
- self.__window.addstr (y - 2, x - 24, '%-4s' % o(self.__status))
- self.__window.addstr (y - 2, x - 19, '%-3s' % o(self.__insert))
- self.__window.addstr (y - 2, x - 15, '%-9s' % recstr)
- self.__window.addstr (y - 2, x - 5, '%-5s' % pagestr)
+ self.__window.addstr(y - 2, 0, '%s' % o(tip))
+ self.__window.addstr(y - 2, x - 24, '%-4s' % o(self.__status))
+ self.__window.addstr(y - 2, x - 19, '%-3s' % o(self.__insert))
+ self.__window.addstr(y - 2, x - 15, '%-9s' % recstr)
+ self.__window.addstr(y - 2, x - 5, '%-5s' % pagestr)
- self.__window.addch (y - 2, x - 25, curses.ACS_VLINE)
- self.__window.addch (y - 2, x - 20, curses.ACS_VLINE)
- self.__window.addch (y - 2, x - 16, curses.ACS_VLINE)
- self.__window.addch (y - 2, x - 6, curses.ACS_VLINE)
+ self.__window.addch(y - 2, x - 25, curses.ACS_VLINE)
+ self.__window.addch(y - 2, x - 20, curses.ACS_VLINE)
+ self.__window.addch(y - 2, x - 16, curses.ACS_VLINE)
+ self.__window.addch(y - 2, x - 6, curses.ACS_VLINE)
- self.__window.bkgdset (' ', self._uiDriver.attr ['fkeys'])
+ self.__window.bkgdset(' ', self._uiDriver.attr ['fkeys'])
- self.__window.addstr (y-1, 0, o(self._uiDriver.getFunctionKeyLine ()))
- self.__window.clrtoeol ()
+ self.__window.addstr(y-1, 0, o(self._uiDriver.getFunctionKeyLine()))
+ self.__window.clrtoeol()
- self.__window.refresh (y - 2, 0, y - 2, 0, y, x)
+ self.__window.refresh(y - 2, 0, y - 2, 0, y, x)
- # ---------------------------------------------------------------------------
- # Close the form
- # ---------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
+ # Close the form
+ # -------------------------------------------------------------------------
- def _ui_close_(self):
+ def _ui_close_(self):
- pass
+ pass
+
# =============================================================================
# Configuration data
# =============================================================================
configuration = {
- 'baseClass' : UIForm,
- 'provides' : 'GFForm',
- 'container' : 1,
- }
+ 'baseClass': UIForm,
+ 'provides' : 'GFForm',
+ 'container': 1,
+}
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2006-11-24
09:46:08 UTC (rev 9061)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/page.py 2006-11-24
10:58:38 UTC (rev 9062)
@@ -41,9 +41,9 @@
caption = getattr(self._gfObject, 'caption', None) or \
self._gfObject.name
- event.parent.addPage(self, caption)
+ event.parent.add_page(self, caption)
- (self.__x1, self.__y1, self.__x2, self.__y2) = event.parent.getCanvas()
+ (self.__x1, self.__y1, self.__x2, self.__y2) =
event.parent.get_canvas()
self.__window = curses.newpad(self.__y2 - self.__y1, self.__x2 -
self.__x1)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9062 - in trunk/gnue-forms/src/uidrivers/curses: . widgets,
johannes <=