commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8353 - in trunk/gnue-forms/src: GFObjects uidrivers/wx26/widgets


From: johannes
Subject: [gnue] r8353 - in trunk/gnue-forms/src: GFObjects uidrivers/wx26/widgets
Date: Tue, 4 Apr 2006 04:06:31 -0500 (CDT)

Author: johannes
Date: 2006-04-04 04:06:30 -0500 (Tue, 04 Apr 2006)
New Revision: 8353

Modified:
   trunk/gnue-forms/src/GFObjects/GFButton.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
Log:
Don't use a subevent handler anymore ... pep8-ified


Modified: trunk/gnue-forms/src/GFObjects/GFButton.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFButton.py  2006-04-04 08:25:01 UTC (rev 
8352)
+++ trunk/gnue-forms/src/GFObjects/GFButton.py  2006-04-04 09:06:30 UTC (rev 
8353)
@@ -30,81 +30,49 @@
 # Class implementing a button
 # =============================================================================
 
-class GFButton (GFTabStop):
+class GFButton(GFTabStop):
 
-  _navigableInQuery_ = False            # Buttons don't get focus in query mode
+    _navigableInQuery_ = False          # Buttons don't get focus in query mode
 
-  # ---------------------------------------------------------------------------
-  # Constructor
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
 
-  def __init__(self, parent=None):
+    def __init__(self, parent=None):
 
-    GFTabStop.__init__(self, parent, 'GFButton')
+        GFTabStop.__init__(self, parent, 'GFButton')
 
-    self.label = ""
+        self.label = ""
 
-    self._validTriggers = {
-      'ON-ACTION'        : 'On-Action',
-      'PRE-FOCUSOUT'     : 'Pre-FocusOut',
-      'POST-FOCUSOUT'    : 'Post-FocusOut',
-      'PRE-FOCUSIN'      : 'Pre-FocusIn',
-      'POST-FOCUSIN'     : 'Post-FocusIn',
-      'ON-NEXT-ENTRY'    : 'On-Next-Entry',
-      'ON-PREVIOUS-ENTRY': 'On-Previous-Entry'}
+        self._validTriggers = {
+          'ON-ACTION'        : 'On-Action',
+          'PRE-FOCUSOUT'     : 'Pre-FocusOut',
+          'POST-FOCUSOUT'    : 'Post-FocusOut',
+          'PRE-FOCUSIN'      : 'Pre-FocusIn',
+          'POST-FOCUSIN'     : 'Post-FocusIn',
+          'ON-NEXT-ENTRY'    : 'On-Next-Entry',
+          'ON-PREVIOUS-ENTRY': 'On-Previous-Entry'}
 
 
-  # ---------------------------------------------------------------------------
-  # Implementation of virtual methods
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Fire the trigger associated with the button from outside GF
+    # -------------------------------------------------------------------------
 
-  def _phase1Init_ (self):
+    def _event_fire(self):
+        """
+        Update the value of the current entry and execute the trigger
+        associated with the button. Use this function to fire a button from the
+        UI layer.
+        """
 
-    GFTabStop._phase1Init_ (self)
+        if hasattr(self._form._currentEntry, '_displayHandler'):
+          self._form._currentEntry._displayHandler.updateFieldValue()
 
-    listeners = {
-      'requestKEYPRESS': self.__handleKEYPRESS,
-      'requestENTER':    self.__handleENTER
-    }
+        self.__fire()
 
-    self.subEventHandler.registerEventListeners (listeners)
+    # -------------------------------------------------------------------------
 
+    def __fire(self):
 
-  # ---------------------------------------------------------------------------
-  # Sub-Eventhandlers
-  # ---------------------------------------------------------------------------
-
-  def __handleKEYPRESS (self, event):
-
-    if event.text == ' ':
-      self.__fire ()
-      event.drop ()
-
-  # ---------------------------------------------------------------------------
-
-  def __handleENTER (self, event):
-    self.__fire ()
-    event.drop ()
-
-
-  # ---------------------------------------------------------------------------
-  # Fire the trigger associated with the button from outside GF
-  # ---------------------------------------------------------------------------
-
-  def _event_fire (self):
-    """
-    Update the value of the current entry and execute the trigger associated
-    with the button. Use this function to fire a button from the UI layer.
-    """
-
-    if hasattr (self._form._currentEntry, '_displayHandler'):
-      self._form._currentEntry._displayHandler.updateFieldValue ()
-
-    self.__fire ()
-
-  # ---------------------------------------------------------------------------
-
-  def __fire (self):
-
-    self.processTrigger ('On-Action', False)
-    self._form.refreshDisplay (self._form)
+        self.processTrigger('On-Action', False)
+        self._form.refreshDisplay(self._form)

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-04-04 
08:25:01 UTC (rev 8352)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/button.py       2006-04-04 
09:06:30 UTC (rev 8353)
@@ -23,72 +23,79 @@
 
 import wx
 
-from gnue.common import events
 from gnue.forms.input import GFKeyMapper
 from gnue.forms.uidrivers.wx26.widgets._base import UIHelper
 
+
 # =============================================================================
 # Wrap an UI layer around a wxButton widget
 # =============================================================================
 
-class UIButton (UIHelper):
-  """
-  Creates a single instance of a button.
-  """
-
-  # --------------------------------------------------------------------------
-  # Create a button widget
-  # --------------------------------------------------------------------------
-
-  def _createWidget (self, event, spacer):
+class UIButton(UIHelper):
     """
-    Creates a new Button widget.
+    Implements a button object
     """
 
-    offs = (self._uiDriver.cellHeight - \
-        self._uiDriver.controlHeight.get ('button', 0)) / 2
-    pos  = (self.itemX, self.itemY + offs)
-    size = (self.itemWidth, -1)
+    # -------------------------------------------------------------------------
+    # Create a button widget
+    # -------------------------------------------------------------------------
 
-    newWidget = wx.Button (event.container, -1, self._gfObject.label, pos, 
size)
-    newWidget.Bind (wx.EVT_BUTTON   , self.__on_button)
-    newWidget.Bind (wx.EVT_SET_FOCUS, self.__on_set_focus)
-    newWidget.Bind (wx.EVT_CHAR, self.__on_char)
+    def _createWidget(self, event, spacer):
+        """
+        Creates a new Button widget.
+        """
 
-    return newWidget
+        offs = (self._uiDriver.cellHeight - \
+                self._uiDriver.controlHeight.get('button', 0)) / 2
+        pos  = (self.itemX, self.itemY + offs)
+        size = (self.itemWidth, -1)
 
+        newWidget = wx.Button(event.container, -1, self._gfObject.label, pos,
+              size)
+        newWidget.Bind(wx.EVT_BUTTON   , self.__on_button)
+        newWidget.Bind(wx.EVT_SET_FOCUS, self.__on_set_focus)
+        newWidget.Bind(wx.EVT_CHAR     , self.__on_char)
 
-  # ---------------------------------------------------------------------------
+        return newWidget
 
-  def __on_char (self, event):
 
-    (command, args) = GFKeyMapper.KeyMapper.getEvent (event.GetKeyCode (),
-          event.ShiftDown (),
-          event.CmdDown (),
-          event.AltDown ())
+    # -------------------------------------------------------------------------
 
-    if command:
-      gDebug (2, "--> COMMAND: %s" % command)
-      self._request (command, triggerName = args)
+    def __on_char (self, event):
 
-    else:
-      event.Skip ()
+        keycode = event.GetKeyCode()
 
-  # ---------------------------------------------------------------------------
+        if keycode in [wx.WXK_SPACE, wx.WXK_RETURN]:
+            self._gfObject._event_fire()
 
-  def __on_button (self, event):
+        else:
+            # For all other keys ask the keymapper if he could do something
+            # usefull
+            (command, args) = GFKeyMapper.KeyMapper.getEvent(keycode,
+                    event.ShiftDown(), event.CmdDown(), event.AltDown())
+
+            if command:
+                self._request(command, triggerName=args)
+
+            else:
+                event.Skip()
+
+
+    # -------------------------------------------------------------------------
+
+    def __on_button (self, event):
     
-    self._gfObject._event_fire ()
+        self._gfObject._event_fire()
 
 
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
 
-  def __on_set_focus (self, event):
+    def __on_set_focus (self, event):
 
-    if self._form._currentEntry != self._gfObject:
-      self._request ('FOCUS', data = self._gfObject)
+        if self._form._currentEntry != self._gfObject:
+            self._request('FOCUS', data=self._gfObject)
 
-    event.Skip ()
+        event.Skip()
 
 
 # =============================================================================





reply via email to

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