[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r6006 - in trunk/gnue-forms/src: . uidrivers/curses uidrivers/curses/wid
From: |
reinhard |
Subject: |
r6006 - in trunk/gnue-forms/src: . uidrivers/curses uidrivers/curses/widgets |
Date: |
Tue, 20 Jul 2004 17:37:50 -0500 (CDT) |
Author: reinhard
Date: 2004-07-20 17:37:50 -0500 (Tue, 20 Jul 2004)
New Revision: 6006
Modified:
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
Log:
Added support for "message boxes" in curses driver.
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2004-07-20 22:36:53 UTC (rev 6005)
+++ trunk/gnue-forms/src/GFInstance.py 2004-07-20 22:37:50 UTC (rev 6006)
@@ -833,8 +833,8 @@
#
# Displays a generic message box
#
- def displayMessageBox (self, message = '', kind = None, cancel = False,
- caption = 'GNUe Message', title = 'Information'):
+ def displayMessageBox (self, message = '', kind = BaseDriver.MBOX_INFO,
+ cancel = False, caption = 'GNUe Message', title = 'Information'):
parameters = {
'caption': caption,
'message': message,
Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2004-07-20 22:36:53 UTC
(rev 6005)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2004-07-20 22:37:50 UTC
(rev 6006)
@@ -44,12 +44,24 @@
self.widgetHeight = 1
self.textWidth = 1
self.textHeight = 1
+
self.__screen = curses.initscr ()
+ curses.raw ()
curses.start_color ()
+ # Color pairs:
+ # 1 = form background
+ # 2 = non-focused entry
+ # 3 = focused entry
+ # 4 = title and status bar
+ # 5 = info message and question
+ # 6 = warning and error message
curses.init_pair (1, curses.COLOR_WHITE, curses.COLOR_BLUE)
curses.init_pair (2, curses.COLOR_WHITE, curses.COLOR_CYAN)
curses.init_pair (3, curses.COLOR_WHITE, curses.COLOR_RED)
curses.init_pair (4, curses.COLOR_WHITE, curses.COLOR_BLACK)
+ curses.init_pair (5, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
+ curses.init_pair (6, curses.COLOR_WHITE, curses.COLOR_RED)
+
self.__exiting = False
# This should go into the base driver:
@@ -203,6 +215,14 @@
pass
# ---------------------------------------------------------------------------
+ # Show a message
+ # ---------------------------------------------------------------------------
+
+ def messageBox (self, message, kind, title, cancel):
+
+ return self.__currentForm.showMessage (message, kind, cancel)
+
+ # ---------------------------------------------------------------------------
# Clean up everything
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2004-07-20
22:36:53 UTC (rev 6005)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/form.py 2004-07-20
22:37:50 UTC (rev 6006)
@@ -23,6 +23,7 @@
import curses
+from gnue.forms.uidrivers._base import UIdriver as BaseDriver
from gnue.forms.uidrivers._base.widgets._base import UIWidget
# =============================================================================
@@ -96,6 +97,47 @@
return self.__currentPage.wait ()
# ---------------------------------------------------------------------------
+ # Show a message
+ # ---------------------------------------------------------------------------
+
+ def showMessage (self, message, kind, cancel):
+
+ attr = {
+ BaseDriver.MBOX_QUESTION: curses.color_pair (5) + curses.A_BOLD,
+ BaseDriver.MBOX_INFO: curses.color_pair (5) + curses.A_BOLD,
+ BaseDriver.MBOX_WARNING: curses.color_pair (6) + curses.A_BOLD,
+ BaseDriver.MBOX_ERROR: curses.color_pair (6) + curses.A_BOLD \
+ + curses.A_BLINK
+ }
+
+ (y, x) = self.__window.getmaxyx ()
+ self.__window.addstr (y - 2, 1, message, attr [kind])
+
+ yes = _("Yes")
+ no = _("No")
+
+ if kind == BaseDriver.MBOX_QUESTION:
+ validKeys = {ord (yes [0]): BaseDriver.RESPONSE_YES,
+ ord (no [0]): BaseDriver.RESPONSE_NO}
+ else:
+ validKeys = {10: BaseDriver.RESPONSE_OK}
+
+ if cancel:
+ validKeys [27] = BaseDriver.RESPONSE_CANCEL
+
+ self.__window.refresh (y - 2, 0, y - 2, 0, y, x)
+
+ while True:
+ key = self.__window.getch ()
+ if validKeys.has_key (key):
+ result = validKeys [key]
+ break
+
+ self.__updateStatusBar ()
+
+ return result
+
+ # ---------------------------------------------------------------------------
# Get free area in the window
# ---------------------------------------------------------------------------
@@ -123,6 +165,17 @@
(y, x) = self.__window.getmaxyx ()
self.__window.refresh (1, 0, 1, 0, 1, x)
+ # ---------------------------------------------------------------------------
+ # Update status bar
+ # ---------------------------------------------------------------------------
+
+ def __updateStatusBar (self):
+
+ (y, x) = self.__window.getmaxyx ()
+ self.__window.move (y - 2, 0)
+ self.__window.clrtobot ()
+ self.__window.refresh (y - 2, 0, y - 2, 0, y, x)
+
# =============================================================================
# Configuration data
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r6006 - in trunk/gnue-forms/src: . uidrivers/curses uidrivers/curses/widgets,
reinhard <=