Changeset 4316

Show
Ignore:
Timestamp:
07/23/08 16:20:31 (1 month ago)
Author:
ed
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dPref.py

    r4314 r4316  
    425425        else: 
    426426            param = "%" 
    427         crs.execute(sql, param
     427        crs.execute(sql, (param,)
    428428        rs = crs.getDataSet() 
    429429        vs = [itm.values()[0] for itm in rs] 
  • trunk/dabo/ui/uiwx/dDateTextBox.py

    r4232 r4316  
    151151                else: 
    152152                    key = {8: "h", 13: "m", 19: "s"}[evt.keyCode] 
    153         except KeyError
     153        except (KeyError, AttributeError)
    154154            # spurious key event; ignore 
    155155            return 
  • trunk/dabo/ui/uiwx/dDialog.py

    r4294 r4316  
    99from dabo.dLocalize import _ 
    1010import dFormMixin as fm 
     11import dPemMixin as pm 
    1112from dabo.ui import makeDynamicProperty 
    1213 
     
    519520        self._baseClass = dOkCancelDialog 
    520521 
     522 
     523 
    521524class dYesNoDialog(dStandardButtonDialog): 
    522525    def __init__(self, parent=None, properties=None, *args, **kwargs): 
     
    527530 
    528531 
     532 
     533class _FloatDialog(dDialog): 
     534    def __init__(self, owner, *args, **kwargs): 
     535        self._above = None 
     536        self._owner = None 
     537        kwargs["Borderless"] = True 
     538        kwargs["FloatOnParent"] = True 
     539        super(_FloatDialog, self).__init__(*args, **kwargs) 
     540 
     541 
     542    def clear(self): 
     543        """Releases any controls remaining from a previous usage.""" 
     544        self.Sizer.clear(True) 
     545 
     546 
     547    def show(self): 
     548        # position by owner 
     549        if self.Owner is None: 
     550            self.Centered = True 
     551        else: 
     552            self.Centered = None 
     553            left, top = self.Owner.absoluteCoordinates() 
     554            self.Left = left 
     555            if self.Above: 
     556                self.Bottom = top 
     557            else: 
     558                self.Top = top + self.Owner.Height 
     559        # Make sure that we're within the display limits 
     560        maxW, maxH = dabo.ui.getDisplaySize() 
     561        self.Left = max(5, self.Left) 
     562        self.Top = max(5, self.Top) 
     563        self.Right = min(self.Right, maxW-5) 
     564        self.Bottom = min(self.Bottom, maxH-5) 
     565        super(_FloatDialog, self).show() 
     566         
     567 
     568    def _getAbove(self): 
     569        return self._above 
     570 
     571    def _setAbove(self, val): 
     572        if self._constructed(): 
     573            self._above = val 
     574        else: 
     575            self._properties["Above"] = val 
     576 
     577 
     578    def _getOwner(self): 
     579        return self._owner 
     580 
     581    def _setOwner(self, val): 
     582        if self._constructed(): 
     583            self._owner = val 
     584        else: 
     585            self._properties["Owner"] = val 
     586 
     587 
     588    Above = property(_getAbove, _setAbove, None, 
     589            _("Is this dialog positioned above its owner? Default=False  (bool)")) 
     590 
     591    Owner = property(_getOwner, _setOwner, None, 
     592            _("Control which is currently managing this window.  (varies)")) 
     593 
     594 
     595 
     596 
     597 
     598 
     599 
     600 
    529601if __name__ == "__main__": 
    530602    import test 
  • trunk/dabo/ui/uiwx/dForm.py

    r4230 r4316  
    1414 
    1515 
    16 class _FloatDialog(dDialog): 
    17     def __init__(self, owner, *args, **kwargs): 
    18         self._above = None 
    19         self._owner = None 
    20         kwargs["Borderless"] = True 
    21         kwargs["FloatOnParent"] = True 
    22         super(_FloatDialog, self).__init__(*args, **kwargs) 
    23  
    24  
    25     def clear(self): 
    26         """Releases any controls remaining from a previous usage.""" 
    27         self.Sizer.clear(True) 
    28  
    29  
    30     def show(self): 
    31         # position by owner 
    32         if self.Owner is None: 
    33             self.Centered = True 
    34         else: 
    35             self.Centered = None 
    36             left, top = self.Owner.absoluteCoordinates() 
    37             self.Left = left 
    38             if self.Above: 
    39                 self.Bottom = top 
    40             else: 
    41                 self.Top = top + self.Owner.Height 
    42         # Make sure that we're within the display limits 
    43         maxW, maxH = dabo.ui.getDisplaySize() 
    44         self.Left = max(5, self.Left) 
    45         self.Top = max(5, self.Top) 
    46         self.Right = min(self.Right, maxW-5) 
    47         self.Bottom = min(self.Bottom, maxH-5) 
    48         super(_FloatDialog, self).show() 
    49          
    50  
    51     def _getAbove(self): 
    52         return self._above 
    53  
    54     def _setAbove(self, val): 
    55         if self._constructed(): 
    56             self._above = val 
    57         else: 
    58             self._properties["Above"] = val 
    59  
    60  
    61     def _getOwner(self): 
    62         return self._owner 
    63  
    64     def _setOwner(self, val): 
    65         if self._constructed(): 
    66             self._owner = val 
    67         else: 
    68             self._properties["Owner"] = val 
    69  
    70  
    71     Above = property(_getAbove, _setAbove, None, 
    72             _("Is this dialog positioned above its owner? Default=False  (bool)")) 
    73  
    74     Owner = property(_getOwner, _setOwner, None, 
    75             _("Control which is currently managing this window.  (varies)")) 
    76  
    77  
    78  
    7916class BaseForm(fm.dFormMixin): 
    8017    """Creates a bizobj-aware form. 
     
    8623        self.bizobjs = {} 
    8724        self._primaryBizobj = None 
    88         self._floatingPanel = None 
    8925         
    9026        # If this is True, a panel will be automatically added to the 
     
    14682            self.activeControlValid() 
    14783            ret = self.confirmChanges() 
    148         if self._floatingPanel: 
    149             self._floatingPanel.release() 
    15084        if ret: 
    15185            ret = super(BaseForm, self)._beforeClose(evt) 
     
    863797         
    864798 
    865     def _getFloatingPanel(self): 
    866         if not self._floatingPanel: 
    867             self._floatingPanel = _FloatDialog(self) 
    868         return self._floatingPanel 
    869  
    870  
    871799    def _getPrimaryBizobj(self): 
    872800        """The attribute '_primaryBizobj' should be a bizobj, but due 
     
    928856            box asking whether to save changes, discard changes, or cancel the  
    929857            operation that led to the dialog being presented.""") ) 
    930  
    931     FloatingPanel = property(_getFloatingPanel, None, None, 
    932             _("""Small modal dialog that is designed to be used for temporary displays,  
    933             similar to context menus, but which can contain any controls.   
    934             (read-only) (dDialog)""")) 
    935858 
    936859    PrimaryBizobj = property(_getPrimaryBizobj, _setPrimaryBizobj, None,  
  • trunk/dabo/ui/uiwx/dFormMixin.py

    r4213 r4316  
    2323        # double-activation is no longer an issue. 
    2424        self._skipActivate = (wx.VERSION < (2,7) and self.Application.Platform == "Win") 
    25  
    2625        self._cxnFile = "" 
    2726        self._cxnName = "" 
    2827        self._connection = None 
     28        self._floatingPanel = None 
     29 
    2930        # Extract the menu definition file, if any 
    3031        self._menuBarFile = self._extractKey((properties, attProperties, kwargs),  
     
    363364        hook method. 
    364365        """ 
     366        if self._floatingPanel: 
     367            self._floatingPanel.release() 
    365368        ret = self.beforeClose(evt) 
    366369        return ret 
     
    659662    def _setCxnName(self, val): 
    660663        self._cxnName = val 
     664 
     665 
     666    def _getFloatingPanel(self): 
     667        if not self._floatingPanel: 
     668            # Have to import it here, as it requires that dFormMixin be defined. 
     669            from dDialog import _FloatDialog 
     670            self._floatingPanel = _FloatDialog(self) 
     671        return self._floatingPanel 
    661672 
    662673 
     
    10221033            _("Name of the connection used for data access  (str)")) 
    10231034     
     1035    FloatingPanel = property(_getFloatingPanel, None, None, 
     1036            _("""Small modal dialog that is designed to be used for temporary displays,  
     1037            similar to context menus, but which can contain any controls.   
     1038            (read-only) (dDialog)""")) 
     1039 
    10241040    FloatOnParent = property(_getFloatOnParent, _setFloatOnParent, None, 
    10251041            _("Specifies whether the form stays on top of the parent or not.")) 
  • trunk/dabo/ui/uiwx/dKeys.py

    r4186 r4316  
    150150    "cmd": mod_Cmd, 
    151151} 
     152 
     153arrows = (key_Up, key_Down, key_Left, key_Right) 
     154whitespace = (key_Tab, key_Space, key_Numpad_space, key_Numpad_tab) 
    152155 
    153156## pkm: I didn't include all the keycodes below - I want to see what is