commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8667 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curs


From: reinhard
Subject: [gnue] r8667 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curses uidrivers/curses/widgets uidrivers/gtk2 uidrivers/gtk2/widgets/form uidrivers/qt uidrivers/qt/widgets/form uidrivers/win32 uidrivers/win32/widgets/form uidrivers/wx uidrivers/wx/widgets/form uidrivers/wx26 uidrivers/wx26/widgets
Date: Mon, 11 Sep 2006 16:39:31 -0500 (CDT)

Author: reinhard
Date: 2006-09-11 16:39:28 -0500 (Mon, 11 Sep 2006)
New Revision: 8667

Modified:
   trunk/gnue-forms/src/GFClient.py
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFInstance.py
   trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
   trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
   trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py
   trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
   trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py
   trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
   trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
   trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
   trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
Log:
Restructured message box and exception dialog methods.


Modified: trunk/gnue-forms/src/GFClient.py
===================================================================
--- trunk/gnue-forms/src/GFClient.py    2006-09-11 19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/GFClient.py    2006-09-11 21:39:28 UTC (rev 8667)
@@ -168,7 +168,7 @@
                            self.disableSplash, userParameters)
 
     # UI is now loaded and in a usable state, so use better exception display
-    self._showException = instance._uiinstance.showException
+    self._showException = instance.show_exception
 
     # Assign the proper login handler based upon the user interface choice
     # FIXME: IMHO, it would be much better if the login handler would be just a

Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-09-11 19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/GFForm.py      2006-09-11 21:39:28 UTC (rev 8667)
@@ -132,17 +132,21 @@
             'setTitle': {
                 'function': self.__trigger_set_title,
                 'global'  : True},
-            'setStatusText': {
-                'function':self.__trigger_status_message,
-                'global': True},
             'getCurrentBlockName': {
                 'function': self.__trigger_get_current_block_name,
                  'global' : True},
             'setFocus': {
                 'function': self.__trigger_set_focus,
                 'global'  : True},
-            'beep': {
-                'function': self.__trigger_beep,
+
+            # User feedback
+            'beep': {'function': self.beep, 'global': True},
+            'status_message': {'function': self.status_message},
+            'show_message': {'function': self.show_message},
+
+            # User feedback - depreciated
+            'setStatusText': {
+                'function': self.status_message,
                 'global': True},
             'showMessage': {
                 'function': self.__trigger_show_message,
@@ -379,16 +383,6 @@
 
     # -------------------------------------------------------------------------
 
-    def __trigger_status_message(self, message):
-        """
-        Display a message in the form's status bar.
-
-        @param message: Message text to display.
-        """
-        self.status_message(message)
-
-    # -------------------------------------------------------------------------
-
     def __trigger_get_current_block_name(self):
         if self._currentBlock is not None:
             return self._currentBlock.name
@@ -426,14 +420,6 @@
 
     # -------------------------------------------------------------------------
 
-    def __trigger_beep(self):
-        """
-        Tell the UI to beep (if possible)
-        """
-        self.beep()
-      
-    # -------------------------------------------------------------------------
-
     def __trigger_show_message(self, msgtxt, caption='GNUe Message',
       title='Information', kind = 'Info', cancel = False):
         """
@@ -446,8 +432,7 @@
         @return: True for <Yes> or <Ok> button, False for <No> button, None for
             <Cancel> button.
         """
-        return self._instance.displayMessageBox (msgtxt, kind, cancel, caption,
-                                                 title)
+        return self.show_message(msgtxt, kind, title, cancel)
 
 
     # -------------------------------------------------------------------------
@@ -463,9 +448,7 @@
         @return: True for <Yes> or <Ok> button, False for <No> button, None for
             <Cancel> button.
         """
-        # FIXME: Should be deprecated in favour of __trigger_show_message
-        return self._instance.displayMessageBox (message, kind, cancel, '',
-                title)
+        return self.show_message(message, kind, title, cancel)
 
     # -------------------------------------------------------------------------
 
@@ -582,7 +565,7 @@
 
 
     # -------------------------------------------------------------------------
-    # Show a message with a beep
+    # User feedback
     # -------------------------------------------------------------------------
 
     def alert_message(self, message):
@@ -590,10 +573,7 @@
         self.status_message(message)
         self.beep()
 
-
     # -------------------------------------------------------------------------
-    # Beep
-    # -------------------------------------------------------------------------
 
     def beep(self):
         """
@@ -602,10 +582,7 @@
         if self.uiWidget is not None:
             self.uiWidget._ui_beep_()
 
-
     # -------------------------------------------------------------------------
-    # Write a message to the status bar
-    # -------------------------------------------------------------------------
 
     def status_message(self, message):
         """
@@ -615,7 +592,21 @@
 
         self.__update_status(tip=message)
 
+    # -------------------------------------------------------------------------
 
+    def show_message(self, message, kind=None, title=None, cancel=False):
+        """
+        This function brings up a message box of a given kind.
+        @param message: text to be displayed
+        @param kind: 'Question', 'Info', 'Warning', or 'Error'
+        @param cancel: Boolean flag indicating wether a cancel button will be
+            included or not.
+        @return: True for <Yes> or <Ok> button, False for <No> button, None for
+            <Cancel> button.
+        """
+        if self.uiWidget is not None:
+            return self.uiWidget._ui_show_message_(message, kind, title, 
cancel)
+
     # -------------------------------------------------------------------------
     # Helper functions to update the status bar of this form
     # -------------------------------------------------------------------------
@@ -1788,8 +1779,8 @@
         if self.isSaved():
             return True
 
-        answer = self._instance.displayMessageBox(message=u_("Save changes?"),
-                kind='Question', cancel=True, title=self.title)
+        answer = self.show_message(message=u_("Save changes?"),
+                kind='Question', title=self.title, cancel=True)
 
         if answer is None:
             # Cancel

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py  2006-09-11 19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/GFInstance.py  2006-09-11 21:39:28 UTC (rev 8667)
@@ -349,6 +349,24 @@
 
 
   # ---------------------------------------------------------------------------
+  # Show an exception
+  # ---------------------------------------------------------------------------
+
+  def show_exception(self, group=None, name=None, message=None, detail=None):
+    """
+    This function shows the last exception raised.
+
+    The exact way of showing the message depends on the exception group.
+    """
+    if (group, name, message, detail) == (None, None, None, None):
+      (group, name, message, detail) = errors.getException()
+    if group == 'user':
+      self._uiinstance._ui_show_error_(message)
+    else:
+      self._uiinstance._ui_show_exception_(group, name, message, detail)
+
+
+  # ---------------------------------------------------------------------------
   # Exit the application if the last form has been closed
   # ---------------------------------------------------------------------------
 
@@ -408,7 +426,7 @@
       # If the entry needs an error message displayed, then the proxied event
       # should set this to the message text
       if event.__errortext__:
-        self.displayMessageBox (event.__errortext__, 'Error')
+        event._form.show_message(event.__errortext__, 'Error')
 
 
   # ---------------------------------------------------------------------------
@@ -437,7 +455,7 @@
       newEntry = event.data
       message = event._form.changeFocus (newEntry)
       if message:
-        self.displayMessageBox (message)
+        event._form.show_message(message)
         return False
 
       self.dispatchEvent ('gotoENTRY', object = event._form._currentEntry,
@@ -473,7 +491,7 @@
     if origEntry == event._form._currentEntry:
       message = event._form.nextEntry ()
       if message:
-        self.displayMessageBox (message)
+        event._form.show_message(message)
         return
 
       self.dispatchEvent ('gotoENTRY', object = event._form._currentEntry,
@@ -757,15 +775,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Display a generic message box
-  # ---------------------------------------------------------------------------
-
-  def displayMessageBox (self, message = '', kind = 'Info', cancel = False,
-      caption = 'GNUe Message', title = None):
-    return self._uiinstance.showMessage (message, kind, title, cancel)
-
-
-  # ---------------------------------------------------------------------------
   # Fire a trigger named 'process-printout' (if it exists)
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py    2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py    2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -93,8 +93,6 @@
   def __init__(self, eventHandler, name = "Undefined", disableSplash = None,
                parentContainer = None, moduleName = None):
     """
-    Constructors of descendants must bring their UI into a state where it can
-    perform simple tasks like showMessage () or showException ().
     """
     # moduleName is here only for Designer to be able to pass it in
     #when debugging a form.
@@ -464,55 +462,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Show the last exception
-  # ---------------------------------------------------------------------------
-
-  def showException (self, group = None, name = None, message = None,
-      detail = None):
-    """
-    This function shows the last exception raised. Exceptions of the user group
-    are delegated to the showMessage-function.
-    """
-    if (group, name, message, detail) == (None, None, None, None):
-      (group, name, message, detail) = errors.getException ()
-    if group == 'user':
-      self.showMessage (message, kind = 'Error', title = _("GNUe Message"))
-    else:
-      self._showException (group, name, message, detail)
-
-
-  # ---------------------------------------------------------------------------
-  # Show a message of a given kind
-  # ---------------------------------------------------------------------------
-
-  def showMessage (self, message, kind = 'Info', title = None, cancel = False):
-    """
-    Show a message box of a given kind and returning a value corresponding with
-    the button pressed to quit the dialog.
-
-    @param message: the text of the message box
-    @param kind: type of the message box. Valid types are: 'Info', 'Warning',
-        'Question', 'Error'
-    @param title: title of the message box
-    @param cancel: If True a cancel button will be added to the dialog
-
-    @return: Depending on the button pressed to quit the message.
-        True : Ok-, Close- or Yes-Button
-        False: No-Button
-        None : Cancel-Button
-    """
-
-    return self._showMessage (message, kind, title, cancel)
-
-
-  # ---------------------------------------------------------------------------
-
-  def _showMessage (self, message, kind = 'Info', title = None, cancel = 
False):
-
-    raise ImplementationError, (self.name, '_showMessage')
-
-
-  # ---------------------------------------------------------------------------
   # Get an input dialog for a given set of fields
   # ---------------------------------------------------------------------------
 
@@ -605,21 +554,3 @@
     set the form's displayed title
     """
     pass
-
-
-  # ---------------------------------------------------------------------------
-  # Abstract: make sure a descendant of this class has a _showException method
-  # ---------------------------------------------------------------------------
-
-  def _showException (self, group, name, message, detail):
-    """
-    This function must be overriden by a descendant UI driver class. It get's
-    called for all exceptions except UserErrors. It's purpose is to display
-    an exception.
-    @param group: Group of the exception like 'system', 'admin', 'application'
-    @param name: Name of the exception, i.e. 'KeyError', 'FoobarError', ...
-    @param message: Message of the exception
-    @param detail: Detail of the exception, i.e. a traceback
-    """
-    raise ImplementationError, (self.name, '_showException')
-

Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -24,6 +24,7 @@
 import atexit
 import curses
 import string
+import sys
 
 from gnue.common.apps import i18n
 from gnue.common.datasources import GLoginHandler
@@ -204,8 +205,8 @@
             (shift, ctrl, meta) = (False, False, False)
 
           self._uiFocusWidget._fkeypress (key, shift, ctrl, meta)
-      except Exception, e:
-        self.showException ()
+      except Exception:
+        sys.excepthook(*sys.exc_info())
 
   # ---------------------------------------------------------------------------
   # Set title of a form
@@ -221,7 +222,7 @@
   # Show a message
   # ---------------------------------------------------------------------------
 
-  def _showMessage (self, message, kind, title, cancel):
+  def showMessage (self, message, kind, cancel):
 
     attr = {
       'Question': self.attr ['infomsg'],
@@ -271,16 +272,24 @@
     return result
 
   # ---------------------------------------------------------------------------
+  # Show a simple error message
+  # ---------------------------------------------------------------------------
+
+  def _ui_show_error_(self, message):
+
+    self.showMessage(message, 'Error', False)
+
+  # ---------------------------------------------------------------------------
   # Show exception information
   # ---------------------------------------------------------------------------
 
-  def _showException (self, group, name, message, detail):
+  def _ui_show_exception_(self, group, name, message, detail):
 
     # Give us a chance to debug exceptions until we have a 'good' exception
     # dialog
     assert gDebug (2, "MESSAGE: %s" % message)
     assert gDebug (2, "Detail : %s" % repr (detail))
-    self.showMessage (message, kind = 'Error')
+    self.showMessage (message, 'Error', False)
 
 
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/form.py       2006-09-11 
19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/form.py       2006-09-11 
21:39:28 UTC (rev 8667)
@@ -117,6 +117,12 @@
     self.__updateStatusBar ()
 
   # ---------------------------------------------------------------------------
+
+  def _ui_show_message_(self, message, kind, title, cancel):
+
+    return self._uiDriver.showMessage(message, kind, cancel)
+
+  # ---------------------------------------------------------------------------
   # Print form screenshot
   # ---------------------------------------------------------------------------
 
@@ -230,6 +236,14 @@
 
     self.__window.refresh (y - 2, 0, y - 2, 0, y, x)
 
+  # ---------------------------------------------------------------------------
+  # Close the form
+  # ---------------------------------------------------------------------------
+
+  def _ui_close_(self):
+
+    pass
+
 # =============================================================================
 # Configuration data
 # =============================================================================

Modified: trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py     2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py     2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -74,22 +74,6 @@
   _WidgetToGFObj = {}
   _WidgetToUIObj = {}
 
-  _MBOX_KIND = {'info'    : {'type'   : gtk.MESSAGE_INFO,
-                             'buttons': gtk.BUTTONS_CLOSE},
-                'warning' : {'type'   : gtk.MESSAGE_WARNING,
-                             'buttons': gtk.BUTTONS_CLOSE},
-                'question': {'type'   : gtk.MESSAGE_QUESTION,
-                             'buttons': gtk.BUTTONS_YES_NO},
-                'error'   : {'type'   : gtk.MESSAGE_ERROR,
-                             'buttons': gtk.BUTTONS_CLOSE}}
-
-  _RESPONSE = {gtk.RESPONSE_OK    : True,
-               gtk.RESPONSE_CLOSE : True,
-               gtk.RESPONSE_YES   : True,
-               gtk.RESPONSE_NO    : False,
-               gtk.RESPONSE_CANCEL: None }
-
-
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------
@@ -202,56 +186,41 @@
     except AttributeError:
       pass
 
+
   # ---------------------------------------------------------------------------
-  # create a modal message box
+  # Start an input dialog and return the data record or None if cancelled
   # ---------------------------------------------------------------------------
 
-  def _showMessage (self, message, kind = 'Info', title = None, cancel = 
False):
-    """
-    This function creates a message box of a given kind and returns True, False
-    or None depending on the button pressed.
-    @param message: the text of the messagebox
-    @param kind: type of the message box. Valid types are 'Info', 'Warning',
-        'Question', 'Error'
-    @param title: title of the message box
-    @param cancel: If True a cancel button will be added to the dialog
-    @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
-        No-button was pressed or None if the Cancel-button was pressed.
-    """
-    mbRec  = self._MBOX_KIND.get (kind.lower ())
-    dialog = gtk.MessageDialog (parent = None, flags = gtk.DIALOG_MODAL,
-        type = mbRec ['type'], buttons = mbRec ['buttons'],
-        message_format = self.__makeSafe (message))
+  def _getInput (self, title, fields, cancel = True):
 
-    if title is not None and len (title):
-      dialog.set_title (self.__makeSafe (title))
+    dialog = dialogs.InputDialog (title, fields, cancel)
+    try:
+      dialog.run ()
+      return dialog.inputData
 
-    cButtons = [gtk.BUTTONS_CANCEL, gtk.BUTTONS_OK_CANCEL]
-    if cancel and not mbRec ['buttons'] in cButtons:
-      dialog.add_button (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+    finally:
+      dialog.destroy ()
 
-    res = dialog.run ()
-    dialog.destroy ()
 
-    return self._RESPONSE [res]
-
-
   # ---------------------------------------------------------------------------
-  # Make sure strings get converted to unicode
+  # create a modal message box
   # ---------------------------------------------------------------------------
 
-  def __makeSafe (self, aValue):
-    if isinstance (aValue, types.StringType):
-      return unicode (aValue, i18n.encoding)
-    else:
-      return aValue
+  def _ui_show_error_(self, message):
 
+    dialog = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL,
+        type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE,
+        message_format=message)
+    dialog.set_title("GNU Enterprise")
+    dialog.run()
+    dialog.destroy()
 
+
   # ---------------------------------------------------------------------------
   # Show an exception dialog
   # ---------------------------------------------------------------------------
 
-  def _showException (self, group, name, message, detail):
+  def _ui_show_exception_(self, group, name, message, detail):
     dialog = ExceptionDisplay (group, name, message, detail)
     try:
       dialog.run ()
@@ -260,21 +229,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Start an input dialog and return the data record or None if cancelled
-  # ---------------------------------------------------------------------------
-
-  def _getInput (self, title, fields, cancel = True):
-
-    dialog = dialogs.InputDialog (title, fields, cancel)
-    try:
-      dialog.run ()
-      return dialog.inputData
-
-    finally:
-      dialog.destroy ()
-
-
-  # ---------------------------------------------------------------------------
   # Process all pending events, but do not block if there are no events
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py  2006-09-11 
19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py  2006-09-11 
21:39:28 UTC (rev 8667)
@@ -33,6 +33,22 @@
 from gnue.forms.uidrivers.gtk2.ToolBar import ToolBar
 
 
+_MBOX_KIND = {'info'    : {'type'   : gtk.MESSAGE_INFO,
+                           'buttons': gtk.BUTTONS_CLOSE},
+              'warning' : {'type'   : gtk.MESSAGE_WARNING,
+                           'buttons': gtk.BUTTONS_CLOSE},
+              'question': {'type'   : gtk.MESSAGE_QUESTION,
+                           'buttons': gtk.BUTTONS_YES_NO},
+              'error'   : {'type'   : gtk.MESSAGE_ERROR,
+                           'buttons': gtk.BUTTONS_CLOSE}}
+
+_RESPONSE = {gtk.RESPONSE_OK    : True,
+             gtk.RESPONSE_CLOSE : True,
+             gtk.RESPONSE_YES   : True,
+             gtk.RESPONSE_NO    : False,
+             gtk.RESPONSE_CANCEL: None }
+
+
 # =============================================================================
 # This class creates a single instance of a form widget
 # =============================================================================
@@ -307,6 +323,41 @@
 
 
   # ---------------------------------------------------------------------------
+  # create a modal message box
+  # ---------------------------------------------------------------------------
+
+  def _ui_show_message_(self, message, kind, title, cancel):
+    """
+    This function creates a message box of a given kind and returns True, False
+    or None depending on the button pressed.
+
+    @param message: the text of the messagebox
+    @param kind: type of the message box. Valid types are 'Info', 'Warning',
+        'Question', 'Error'
+    @param title: title of the message box
+    @param cancel: If True a cancel button will be added to the dialog
+    @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
+        No-button was pressed or None if the Cancel-button was pressed.
+    """
+    mbRec  = _MBOX_KIND.get (kind.lower ())
+    dialog = gtk.MessageDialog (parent = self.mainWindow,
+            flags = gtk.DIALOG_MODAL, type = mbRec ['type'],
+            buttons = mbRec ['buttons'], message_format = message)
+
+    if title is not None and len (title):
+      dialog.set_title (title)
+
+    cButtons = [gtk.BUTTONS_CANCEL, gtk.BUTTONS_OK_CANCEL]
+    if cancel and not mbRec ['buttons'] in cButtons:
+      dialog.add_button (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+
+    res = dialog.run ()
+    dialog.destroy ()
+
+    return _RESPONSE [res]
+
+
+  # ---------------------------------------------------------------------------
   # Display an about box
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/UIdriver.py       2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/qt/UIdriver.py       2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -61,14 +61,6 @@
 # All UIs must provide this class
 #
 class GFUserInterface(commonToolkit.GFUserInterface):
-  _MBOX_KIND = {'Info'    : {'style': QMessageBox.information,
-                                 'title': _("Information")},
-                'Warning' : {'style': QMessageBox.warning,
-                             'title': _("Warning")},
-                'Question': {'style': QInputDialog.getText,
-                             'title': _("Question")},
-                'Error'   : {'style': QMessageBox.critical,
-                             'title': _("Error")}}
 
   def initialize(self):
 
@@ -184,14 +176,8 @@
       object = _eventObjToQtWindow(event)
       object.Destroy()
   
-  def _showMessage (self, message, kind = 'Info', title = None, cancel = 
False):
+  def _ui_show_error_(self, message):
+    QMessageBox.critical(None, "GNU Enterprise", message)
 
-    boxClass = self._MBOX_KIND [kind]['style']
-
-    if title is None:
-      title = self._MBOX_KIND [kind]['title']
-    result = boxClass (None, title, lineWrap(message,80))
-
-  def _showException (self, group, name, message, detail):
-    self._showMessage (detail, 'Error')
-
+  def _ui_show_exception_(self, group, name, message, detail):
+    self._ui_show_error_(detail)

Modified: trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py    2006-09-11 
19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/uidrivers/qt/widgets/form/widget.py    2006-09-11 
21:39:28 UTC (rev 8667)
@@ -38,7 +38,15 @@
 
 import wrappers
 
-#
+_MBOX_KIND = {'Info'    : {'style': QMessageBox.information,
+                           'title': _("Information")},
+              'Warning' : {'style': QMessageBox.warning,
+                           'title': _("Warning")},
+              'Question': {'style': QInputDialog.getText,
+                           'title': _("Question")},
+              'Error'   : {'style': QMessageBox.critical,
+                           'title': _("Error")}}
+
 # UIForm
 #
 # Widget set specific function that creates a single instance of a Form widget
@@ -228,3 +236,12 @@
     pageWidth   = pageWidth   and (pageWidth   * 2) or 5
 
     
self.statusBar.SetStatusWidths([tipWidth,statusWidth,insertWidth,recordWidth,pageWidth])
+
+
+  def _ui_show_message_(self, message, kind, title, cancel):
+
+    boxClass = _MBOX_KIND [kind]['style']
+
+    if title is None:
+      title = _MBOX_KIND [kind]['title']
+    result = boxClass (None, title, lineWrap(message,80))

Modified: trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UIdriver.py    2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/win32/UIdriver.py    2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -93,24 +93,6 @@
 #
 class GFUserInterface(commonToolkit.GFUserInterface):
 
-  _MBOX_KIND = {'Info'    : {'type'   : _('Info'),
-                             'icon'   : win32con.MB_ICONINFORMATION,
-                             'buttons': win32con.MB_OK},
-                'Warning' : {'type'   : _('Warning'),
-                             'icon'   : win32con.MB_ICONWARNING,
-                             'buttons': win32con.MB_OK},
-                'Question': {'type'   : _('Question'),
-                             'icon'   : win32con.MB_ICONQUESTION,
-                             'buttons': win32con.MB_YESNO},
-                'Error'   : {'type'   : _('Error'),
-                             'icon'   : win32con.MB_ICONERROR,
-                             'buttons': win32con.MB_OK}}
-
-  _RESPONSE = {win32con.IDOK    : True,
-               win32con.IDYES   : True,
-               win32con.IDNO    : False,
-               win32con.IDCANCEL: None }
-
   _message_map = { win32con.WM_VSCROLL    : OnWMVScroll,
                    win32con.WM_MENUSELECT : OnWMMenuselect,
                    win32con.WM_NOTIFY     : OnWMNotify,
@@ -260,44 +242,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # create a modal message box
-  # ---------------------------------------------------------------------------
-
-  def _showMessage (self, message, kind = 'Info', title = None, cancel = 
False):
-    """
-    This function creates a message box of a given kind and returns True, False
-    or None depending on the button pressed.
-    @param message: the text of the messagebox
-    @param kind: type of the message box. Valid types are 'Info', 'Warning',
-        'Question', 'Error'
-    @param title: title of the message box
-    @param cancel: If True a cancel button will be added to the dialog
-    @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
-        No-button was pressed or None if the Cancel-button was pressed.
-    """
-    mbRec  = self._MBOX_KIND.get (kind)
-    flags = win32con.MB_TASKMODAL | mbRec['icon'] | mbRec['buttons']
-
-    if title is not None and len (title):
-      if isinstance (title, types.StringType):
-        title = unicode (title, i18n.encoding)
-    else:
-      title = mbRec['type']
-
-    cButtons = [win32con.MB_OKCANCEL, win32con.MB_YESNOCANCEL]
-
-    if cancel and not mbRec ['buttons'] in cButtons:
-      if mbRec ['buttons'] == win32con.MB_OK:
-        flags = flags | win32con.MB_OKCANCEL
-      elif mbRec ['buttons'] == win32con.MB_YESNO:
-        flags = flags | win32con.MB_YESNOCANCEL
-
-    res = win32gui.MessageBox(0, message, title, flags)
-
-    return self._RESPONSE [res]
-
-
-  # ---------------------------------------------------------------------------
   # Start an input dialog and return the data record or None if cancelled
   # ---------------------------------------------------------------------------
 
@@ -309,15 +253,25 @@
 
 
   # ---------------------------------------------------------------------------
+  # Show a simple error message
+  # ---------------------------------------------------------------------------
+
+  def _ui_show_error_(self, message):
+
+    win32gui.MessageBox(0, message, "GNU Enterprise",
+            win32con.MB_TASKMODAL | win32con.MB_ICONERROR | win32con.MB_OK)
+
+
+  # ---------------------------------------------------------------------------
   # Show an exception
   # ---------------------------------------------------------------------------
 
-  def _showException (self, group, name, message, detail):
+  def _ui_show_exception_(self, group, name, message, detail):
       
     dialog = ExceptionDisplay (group, name, message, detail)
     dialog.DoModal ()
-
-
+
+
   # ---------------------------------------------------------------------------
   # Exit the application
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-09-11 
19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-09-11 
21:39:28 UTC (rev 8667)
@@ -40,7 +40,24 @@
 from gnue.forms.uidrivers.win32.ToolBar import ToolBar
 import wrappers
 
+_MBOX_KIND = {'Info'    : {'type'   : _('Info'),
+                           'icon'   : win32con.MB_ICONINFORMATION,
+                           'buttons': win32con.MB_OK},
+              'Warning' : {'type'   : _('Warning'),
+                           'icon'   : win32con.MB_ICONWARNING,
+                           'buttons': win32con.MB_OK},
+              'Question': {'type'   : _('Question'),
+                           'icon'   : win32con.MB_ICONQUESTION,
+                           'buttons': win32con.MB_YESNO},
+              'Error'   : {'type'   : _('Error'),
+                           'icon'   : win32con.MB_ICONERROR,
+                           'buttons': win32con.MB_OK}}
 
+_RESPONSE = {win32con.IDOK    : True,
+             win32con.IDYES   : True,
+             win32con.IDNO    : False,
+             win32con.IDCANCEL: None }
+
 #
 # UIForm
 #
@@ -211,6 +228,44 @@
 
 
   # ---------------------------------------------------------------------------
+  # create a modal message box
+  # ---------------------------------------------------------------------------
+
+  def _ui_show_message_(self, message, kind, title, cancel):
+    """
+    This function creates a message box of a given kind and returns True, False
+    or None depending on the button pressed.
+    @param message: the text of the messagebox
+    @param kind: type of the message box. Valid types are 'Info', 'Warning',
+        'Question', 'Error'
+    @param title: title of the message box
+    @param cancel: If True a cancel button will be added to the dialog
+    @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
+        No-button was pressed or None if the Cancel-button was pressed.
+    """
+    mbRec  = _MBOX_KIND.get (kind)
+    flags = win32con.MB_TASKMODAL | mbRec['icon'] | mbRec['buttons']
+
+    if title is not None and len (title):
+      if isinstance (title, types.StringType):
+        title = unicode (title, i18n.encoding)
+    else:
+      title = mbRec['type']
+
+    cButtons = [win32con.MB_OKCANCEL, win32con.MB_YESNOCANCEL]
+
+    if cancel and not mbRec ['buttons'] in cButtons:
+      if mbRec ['buttons'] == win32con.MB_OK:
+        flags = flags | win32con.MB_OKCANCEL
+      elif mbRec ['buttons'] == win32con.MB_YESNO:
+        flags = flags | win32con.MB_YESNOCANCEL
+
+    res = win32gui.MessageBox(0, message, title, flags)
+
+    return _RESPONSE [res]
+
+
+  # ---------------------------------------------------------------------------
   # Display an about box
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py       2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -56,20 +56,7 @@
   The public interface to a GNUe Forms user interface
   All UI drivers must provide this class
   """
-  _MBOX_KIND = {'Info'    : {'style': wxICON_INFORMATION | wxOK,
-                             'title': _("Information")},
-                'Warning' : {'style': wxICON_EXCLAMATION | wxOK,
-                             'title': _("Warning")},
-                'Question': {'style': wxICON_QUESTION    | wxYES_NO,
-                             'title': _("Question")},
-                'Error'   : {'style': wxICON_ERROR       | wxOK,
-                             'title': _("Error")}}
 
-  _RESPONSE = {wxID_OK    : True,
-               wxID_YES   : True,
-               wxID_NO    : False,
-               wxID_CANCEL: None}
-
   def _initialize(self):
 
     ################################################################
@@ -200,36 +187,31 @@
   #
 
   # ---------------------------------------------------------------------------
-  # Show a message dialog
+  # Start an input dialog and return the data record or None if cancelled
   # ---------------------------------------------------------------------------
 
-  def _showMessage (self, message, kind = 'Info', title = None, cancel = 
False):
+  def _getInput (self, title, fields, cancel = True):
 
-    style = self._MBOX_KIND [kind]['style']
-    if cancel:
-      style |= wxCANCEL
-
-    if title is None:
-      title = self._MBOX_KIND [kind]['title']
-    dialog = wxMessageDialog (None, wxEncode (lineWrap(message,80)), wxEncode 
(title), style)
+    dialog = dialogs.InputDialog (title, fields, cancel)
     try:
-      result = dialog.ShowModal ()
-      return self._RESPONSE [result]
+      dialog.ShowModal ()
+      return dialog.inputData
 
     finally:
       dialog.Destroy ()
 
 
   # ---------------------------------------------------------------------------
-  # Start an input dialog and return the data record or None if cancelled
+  # Show a message dialog
   # ---------------------------------------------------------------------------
 
-  def _getInput (self, title, fields, cancel = True):
+  def _ui_show_error_(self, message):
 
-    dialog = dialogs.InputDialog (title, fields, cancel)
+    dialog = wxMessageDialog (None, wxEncode (lineWrap(message,80)),
+            "GNU Enterprise", wxICON_ERROR | wxOK)
     try:
-      dialog.ShowModal ()
-      return dialog.inputData
+      result = dialog.ShowModal ()
+      return self._RESPONSE [result]
 
     finally:
       dialog.Destroy ()
@@ -241,9 +223,9 @@
   #       detail-display and so on
   # ---------------------------------------------------------------------------
 
-  def _showException (self, group, name, message, detail):
+  def _ui_show_exception_(self, group, name, message, detail):
 
-    self._showMessage (wxEncode (detail), 'Error')
+    self._ui_show_error_(wxEncode(detail))
 
 
   # ---------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py    2006-09-11 
19:46:28 UTC (rev 8666)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py    2006-09-11 
21:39:28 UTC (rev 8667)
@@ -29,6 +29,7 @@
 
 from wxPython.wx import *
 from gnue.common import events
+from gnue.common.utils.TextUtils import lineWrap
 from gnue.forms.uidrivers.wx.common import _eventObjTowxWindow, wxEncode, 
initFont
 from gnue.forms.uidrivers.wx.widgets._base import UIHelper
 
@@ -40,6 +41,21 @@
 from PrintForm import printForm
 
 
+_MBOX_KIND = {'Info'    : {'style': wxICON_INFORMATION | wxOK,
+                           'title': _("Information")},
+              'Warning' : {'style': wxICON_EXCLAMATION | wxOK,
+                           'title': _("Warning")},
+              'Question': {'style': wxICON_QUESTION    | wxYES_NO,
+                           'title': _("Question")},
+              'Error'   : {'style': wxICON_ERROR       | wxOK,
+                           'title': _("Error")}}
+
+_RESPONSE = {wxID_OK    : True,
+             wxID_YES   : True,
+             wxID_NO    : False,
+             wxID_CANCEL: None}
+
+
 # =============================================================================
 # Wrap an UI layer around a wx Form widget
 # =============================================================================
@@ -235,6 +251,28 @@
 
 
   # ---------------------------------------------------------------------------
+  # Show a message dialog
+  # ---------------------------------------------------------------------------
+
+  def _ui_show_message_(self, message, kind, title, cancel):
+
+    style = _MBOX_KIND [kind]['style']
+    if cancel:
+      style |= wxCANCEL
+
+    if title is None:
+      title = _MBOX_KIND [kind]['title']
+    dialog = wxMessageDialog (None, wxEncode (lineWrap(message,80)),
+            wxEncode (title), style)
+    try:
+      result = dialog.ShowModal ()
+      return _RESPONSE [result]
+
+    finally:
+      dialog.Destroy ()
+
+
+  # ---------------------------------------------------------------------------
   # Display an about box
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py     2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py     2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -53,24 +53,6 @@
   An implementation of the common GUI toolkit interface using wx 2.6+.
   """
 
-  _MBOX_KIND = {'info'    : {'type'   : wx.ICON_INFORMATION,
-                             'buttons': wx.OK,
-                             'title'  : u_("Information")},
-                'warning' : {'type'   : wx.ICON_EXCLAMATION,
-                             'buttons': wx.OK,
-                             'title'  : u_("Warning")},
-                'question': {'type'   : wx.ICON_QUESTION,
-                             'buttons': wx.YES_NO,
-                             'title'  : u_("Question")},
-                'error'   : {'type'   : wx.ICON_ERROR,
-                             'buttons': wx.OK,
-                             'title'  : u_("Error")}}
-
-  _RESPONSE = {wx.ID_OK    : True,
-               wx.ID_YES   : True,
-               wx.ID_NO    : False,
-               wx.ID_CANCEL: None }
-
   # ---------------------------------------------------------------------------
   # Constructor
   # ---------------------------------------------------------------------------
@@ -203,46 +185,45 @@
       assert gDebug(6,"Set Clipboard Status: %s" % value)
       wx.TheClipboard.Close()
 
+
   # ---------------------------------------------------------------------------
-  # create a modal message box
+  # Create and run an input dialog
   # ---------------------------------------------------------------------------
 
-  def _showMessage (self, message, kind = 'Info', title = None, cancel = 
False):
-    """
-    This function creates a message box of a given kind and returns True, False
-    or None depending on the button pressed.
+  def _getInput (self, title, fields, cancel = True):
+    
+    dialog = dialogs.InputDialog (title, fields, cancel)
 
-    @param message: the text of the messagebox
-    @param kind: type of the message box. Valid types are 'Info', 'Warning',
-        'Question', 'Error'
-    @param title: title of the message box
-    @param cancel: If True a cancel button will be added to the dialog
-
-    @return: True if the Ok-, Close-, or Yes-button was pressed, False if the
-        No-button was pressed or None if the Cancel-button was pressed.
-    """
-
-    mbRec  = self._MBOX_KIND.get (kind.lower ())
-    flags  = mbRec ['type'] | mbRec ['buttons']
-    if cancel:
-        flags |= wx.CANCEL
-    title  = title and title or mbRec ['title']
-
-    dialog = wx.MessageDialog (None, message, title, flags)
     try:
-      result = dialog.ShowModal ()
+      dialog.ShowModal ()
+      return dialog.inputData
 
     finally:
       dialog.Destroy ()
 
-    return self._RESPONSE [result]
 
+  # ---------------------------------------------------------------------------
+  # Show a simple error message
+  # ---------------------------------------------------------------------------
 
+  def _ui_show_error_(self, message):
+
+        if self.__splash:
+            self.__splash.Close()
+
+        dialog = wx.MessageDialog(None, message, "GNU Enterprise",
+                wx.ICON_ERROR | wx.OK)
+        try:
+            result = dialog.ShowModal()
+        finally:
+            dialog.Destroy()
+
+
   # ---------------------------------------------------------------------------
   # Show an exception dialog
   # ---------------------------------------------------------------------------
 
-  def _showException (self, group, name, message, detail):
+  def _ui_show_exception_(self, group, name, message, detail):
 
     if self.__splash:
         self.__splash.Close()
@@ -256,22 +237,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Create and run an input dialog
-  # ---------------------------------------------------------------------------
-
-  def _getInput (self, title, fields, cancel = True):
-    
-    dialog = dialogs.InputDialog (title, fields, cancel)
-
-    try:
-      dialog.ShowModal ()
-      return dialog.inputData
-
-    finally:
-      dialog.Destroy ()
-
-
-  # ---------------------------------------------------------------------------
   # Exit the application
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-09-11 19:46:28 UTC 
(rev 8666)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-09-11 21:39:28 UTC 
(rev 8667)
@@ -37,6 +37,24 @@
 
 __all__ = ['UIForm']
 
+_MBOX_KIND = {'info'    : {'type'   : wx.ICON_INFORMATION,
+                           'buttons': wx.OK,
+                           'title'  : u_("Information")},
+              'warning' : {'type'   : wx.ICON_EXCLAMATION,
+                           'buttons': wx.OK,
+                           'title'  : u_("Warning")},
+              'question': {'type'   : wx.ICON_QUESTION,
+                           'buttons': wx.YES_NO,
+                           'title'  : u_("Question")},
+              'error'   : {'type'   : wx.ICON_ERROR,
+                           'buttons': wx.OK,
+                           'title'  : u_("Error")}}
+
+_RESPONSE = {wx.ID_OK    : True,
+             wx.ID_YES   : True,
+             wx.ID_NO    : False,
+             wx.ID_CANCEL: None }
+
 # =============================================================================
 # Interface implementation of a form widget
 # =============================================================================
@@ -344,7 +362,38 @@
             self.__status_bar.SetStatusText(
                     "%s/%s" % (page_number, page_count), 4)
 
+    # -------------------------------------------------------------------------
 
+    def _ui_show_message_(self, message, kind, title, cancel):
+        """
+        This function creates a message box of a given kind and returns True,
+        False or None depending on the button pressed.
+
+        @param message: the text of the messagebox
+        @param kind: type of the message box. Valid types are 'Info',
+            'Warning', 'Question', 'Error'
+        @param title: title of the message box
+        @param cancel: If True a cancel button will be added to the dialog
+
+        @return: True if the Ok-, Close-, or Yes-button was pressed, False if
+            the No-button was pressed or None if the Cancel-button was pressed.
+        """
+
+        mbRec  = _MBOX_KIND.get(kind.lower())
+        flags  = mbRec['type'] | mbRec['buttons']
+        if cancel:
+            flags |= wx.CANCEL
+        title  = title and title or mbRec['title']
+
+        dialog = wx.MessageDialog(self.main_window, message, title, flags)
+        try:
+            result = dialog.ShowModal()
+        finally:
+            dialog.Destroy()
+
+        return _RESPONSE[result]
+
+
     # -------------------------------------------------------------------------
     # Change the page
     # -------------------------------------------------------------------------





reply via email to

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