dabo Commit
Revision 4316
Date: 2008-07-23 16:20:31 -0700 (Wed, 23 Jul 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4316

Changed:
U   trunk/dabo/dPref.py
U   trunk/dabo/ui/uiwx/dDateTextBox.py
U   trunk/dabo/ui/uiwx/dDialog.py
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dFormMixin.py
U   trunk/dabo/ui/uiwx/dKeys.py

Log:
Moved the FloatingPanel code into dDialog and dFormMixin, so that it is 
available in all form classes.

Fixed an unhandled exception in dDateTextBox.

Fixed a bug in the execute command in dPref.

Added some convenience attributes to dKeys.


Diff:
Modified: trunk/dabo/dPref.py
===================================================================
--- trunk/dabo/dPref.py 2008-07-23 21:50:05 UTC (rev 4315)
+++ trunk/dabo/dPref.py 2008-07-23 23:20:31 UTC (rev 4316)
@@ -424,7 +424,7 @@
                        param = "%s.%%" % key
                else:
                        param = "%"
-               crs.execute(sql, param)
+               crs.execute(sql, (param,))
                rs = crs.getDataSet()
                vs = [itm.values()[0] for itm in rs]
 

Modified: trunk/dabo/ui/uiwx/dDateTextBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dDateTextBox.py  2008-07-23 21:50:05 UTC (rev 4315)
+++ trunk/dabo/ui/uiwx/dDateTextBox.py  2008-07-23 23:20:31 UTC (rev 4316)
@@ -150,7 +150,7 @@
                                        key = {72: "h", 77: "m", 83: 
"s"}[evt.keyCode]
                                else:
                                        key = {8: "h", 13: "m", 19: 
"s"}[evt.keyCode]
-               except KeyError:
+               except (KeyError, AttributeError):
                        # spurious key event; ignore
                        return
                

Modified: trunk/dabo/ui/uiwx/dDialog.py
===================================================================
--- trunk/dabo/ui/uiwx/dDialog.py       2008-07-23 21:50:05 UTC (rev 4315)
+++ trunk/dabo/ui/uiwx/dDialog.py       2008-07-23 23:20:31 UTC (rev 4316)
@@ -8,6 +8,7 @@
 import dabo.dConstants as kons
 from dabo.dLocalize import _
 import dFormMixin as fm
+import dPemMixin as pm
 from dabo.ui import makeDynamicProperty
 
 
@@ -518,6 +519,8 @@
                super(dOkCancelDialog, self).__init__(parent, properties, 
*args, **kwargs)
                self._baseClass = dOkCancelDialog
 
+
+
 class dYesNoDialog(dStandardButtonDialog):
        def __init__(self, parent=None, properties=None, *args, **kwargs):
                kwargs["Yes"] = kwargs["No"] = True
@@ -526,6 +529,75 @@
                self._baseClass = dYesNoDialog
 
 
+
+class _FloatDialog(dDialog):
+       def __init__(self, owner, *args, **kwargs):
+               self._above = None
+               self._owner = None
+               kwargs["Borderless"] = True
+               kwargs["FloatOnParent"] = True
+               super(_FloatDialog, self).__init__(*args, **kwargs)
+
+
+       def clear(self):
+               """Releases any controls remaining from a previous usage."""
+               self.Sizer.clear(True)
+
+
+       def show(self):
+               # position by owner
+               if self.Owner is None:
+                       self.Centered = True
+               else:
+                       self.Centered = None
+                       left, top = self.Owner.absoluteCoordinates()
+                       self.Left = left
+                       if self.Above:
+                               self.Bottom = top
+                       else:
+                               self.Top = top + self.Owner.Height
+               # Make sure that we're within the display limits
+               maxW, maxH = dabo.ui.getDisplaySize()
+               self.Left = max(5, self.Left)
+               self.Top = max(5, self.Top)
+               self.Right = min(self.Right, maxW-5)
+               self.Bottom = min(self.Bottom, maxH-5)
+               super(_FloatDialog, self).show()
+               
+
+       def _getAbove(self):
+               return self._above
+
+       def _setAbove(self, val):
+               if self._constructed():
+                       self._above = val
+               else:
+                       self._properties["Above"] = val
+
+
+       def _getOwner(self):
+               return self._owner
+
+       def _setOwner(self, val):
+               if self._constructed():
+                       self._owner = val
+               else:
+                       self._properties["Owner"] = val
+
+
+       Above = property(_getAbove, _setAbove, None,
+                       _("Is this dialog positioned above its owner? 
Default=False  (bool)"))
+
+       Owner = property(_getOwner, _setOwner, None,
+                       _("Control which is currently managing this window.  
(varies)"))
+
+
+
+
+
+
+
+
 if __name__ == "__main__":
        import test
        test.Test().runTest(dDialog)

Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2008-07-23 21:50:05 UTC (rev 4315)
+++ trunk/dabo/ui/uiwx/dForm.py 2008-07-23 23:20:31 UTC (rev 4316)
@@ -13,69 +13,6 @@
 from dDialog import dDialog
 
 
-class _FloatDialog(dDialog):
-       def __init__(self, owner, *args, **kwargs):
-               self._above = None
-               self._owner = None
-               kwargs["Borderless"] = True
-               kwargs["FloatOnParent"] = True
-               super(_FloatDialog, self).__init__(*args, **kwargs)
-
-
-       def clear(self):
-               """Releases any controls remaining from a previous usage."""
-               self.Sizer.clear(True)
-
-
-       def show(self):
-               # position by owner
-               if self.Owner is None:
-                       self.Centered = True
-               else:
-                       self.Centered = None
-                       left, top = self.Owner.absoluteCoordinates()
-                       self.Left = left
-                       if self.Above:
-                               self.Bottom = top
-                       else:
-                               self.Top = top + self.Owner.Height
-               # Make sure that we're within the display limits
-               maxW, maxH = dabo.ui.getDisplaySize()
-               self.Left = max(5, self.Left)
-               self.Top = max(5, self.Top)
-               self.Right = min(self.Right, maxW-5)
-               self.Bottom = min(self.Bottom, maxH-5)
-               super(_FloatDialog, self).show()
-               
-
-       def _getAbove(self):
-               return self._above
-
-       def _setAbove(self, val):
-               if self._constructed():
-                       self._above = val
-               else:
-                       self._properties["Above"] = val
-
-
-       def _getOwner(self):
-               return self._owner
-
-       def _setOwner(self, val):
-               if self._constructed():
-                       self._owner = val
-               else:
-                       self._properties["Owner"] = val
-
-
-       Above = property(_getAbove, _setAbove, None,
-                       _("Is this dialog positioned above its owner? 
Default=False  (bool)"))
-
-       Owner = property(_getOwner, _setOwner, None,
-                       _("Control which is currently managing this window.  
(varies)"))
-
-
-
 class BaseForm(fm.dFormMixin):
        """Creates a bizobj-aware form.
 
@@ -85,7 +22,6 @@
        def __init__(self, preClass, parent, properties, attProperties, *args, 
**kwargs):
                self.bizobjs = {}
                self._primaryBizobj = None
-               self._floatingPanel = None
                
                # If this is True, a panel will be automatically added to the
                # form and sized to fill the form.
@@ -145,8 +81,6 @@
                if not self._isClosed:
                        self.activeControlValid()
                        ret = self.confirmChanges()
-               if self._floatingPanel:
-                       self._floatingPanel.release()
                if ret:
                        ret = super(BaseForm, self)._beforeClose(evt)
                return ret
@@ -862,12 +796,6 @@
                self._checkForChanges = bool(value)
                
 
-       def _getFloatingPanel(self):
-               if not self._floatingPanel:
-                       self._floatingPanel = _FloatDialog(self)
-               return self._floatingPanel
-
-
        def _getPrimaryBizobj(self):
                """The attribute '_primaryBizobj' should be a bizobj, but due
                to old code design, might be a data source name. These methods
@@ -928,11 +856,6 @@
                        box asking whether to save changes, discard changes, or 
cancel the 
                        operation that led to the dialog being presented.""") )
 
-       FloatingPanel = property(_getFloatingPanel, None, None,
-                       _("""Small modal dialog that is designed to be used for 
temporary displays, 
-                       similar to context menus, but which can contain any 
controls.  
-                       (read-only) (dDialog)"""))
-
        PrimaryBizobj = property(_getPrimaryBizobj, _setPrimaryBizobj, None, 
                        _("Reference to the primary bizobj for this form  
(dBizobj)") )
 

Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py    2008-07-23 21:50:05 UTC (rev 4315)
+++ trunk/dabo/ui/uiwx/dFormMixin.py    2008-07-23 23:20:31 UTC (rev 4316)
@@ -22,10 +22,11 @@
                # Skip the first one. Update: apparently on wx27 and above the 
                # double-activation is no longer an issue.
                self._skipActivate = (wx.VERSION < (2,7) and 
self.Application.Platform == "Win")
-
                self._cxnFile = ""
                self._cxnName = ""
                self._connection = None
+               self._floatingPanel = None
+
                # Extract the menu definition file, if any
                self._menuBarFile = self._extractKey((properties, 
attProperties, kwargs), 
                                "MenuBarFile", "")
@@ -362,6 +363,8 @@
                form is set for checking for this. If everything's OK, call the 
                hook method.
                """
+               if self._floatingPanel:
+                       self._floatingPanel.release()
                ret = self.beforeClose(evt)
                return ret
                
@@ -660,6 +663,14 @@
                self._cxnName = val
 
 
+       def _getFloatingPanel(self):
+               if not self._floatingPanel:
+                       # Have to import it here, as it requires that 
dFormMixin be defined.
+                       from dDialog import _FloatDialog
+                       self._floatingPanel = _FloatDialog(self)
+               return self._floatingPanel
+
+
        def _getFloatOnParent(self):
                return self._hasWindowStyleFlag(wx.FRAME_FLOAT_ON_PARENT)
 
@@ -1021,6 +1032,11 @@
        CxnName = property(_getCxnName, _setCxnName, None,
                        _("Name of the connection used for data access  (str)"))
        
+       FloatingPanel = property(_getFloatingPanel, None, None,
+                       _("""Small modal dialog that is designed to be used for 
temporary displays, 
+                       similar to context menus, but which can contain any 
controls.  
+                       (read-only) (dDialog)"""))
+
        FloatOnParent = property(_getFloatOnParent, _setFloatOnParent, None,
                        _("Specifies whether the form stays on top of the 
parent or not."))
        

Modified: trunk/dabo/ui/uiwx/dKeys.py
===================================================================
--- trunk/dabo/ui/uiwx/dKeys.py 2008-07-23 21:50:05 UTC (rev 4315)
+++ trunk/dabo/ui/uiwx/dKeys.py 2008-07-23 23:20:31 UTC (rev 4316)
@@ -150,6 +150,9 @@
        "cmd": mod_Cmd,
 }
 
+arrows = (key_Up, key_Down, key_Left, key_Right)
+whitespace = (key_Tab, key_Space, key_Numpad_space, key_Numpad_tab)
+
 ## pkm: I didn't include all the keycodes below - I want to see what is
 ##      actually necessary to add. Do we really need separate codes for
 ##      the '*' on the numpad versus the '*' on the keyboard, for instance.




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to