Changeset 2458

Show
Ignore:
Timestamp:
11/15/06 16:54:27 (2 years ago)
Author:
ed
Message:

Added a 'Visible' property to the dColumn class. Setting it to False will hide the column; setting it back to True returns the column to its original visible status.

Added column information to the mouse events on the grid headers.

Fixed a problem with the Children property of dSpinner returning references to its textbox and spin buttons, neither of which are Dabo objects. Also localized some docstrings.

Fixed a bug in dPemMixin.setAll() if an object's Children propety returned None.

Removed some unneeded code from dHtmlBox; enhanced the test code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/uiwx/dGrid.py

    r2415 r2458  
    433433        # Do text columns wrap their long text? 
    434434        self._wordWrap = False 
     435        # Is the column shown? 
     436        self._visible = True 
    435437 
    436438        self._beforeInit() 
     
    12101212 
    12111213 
     1214    def _getVisible(self): 
     1215        return self._visible 
     1216 
     1217    def _setVisible(self, val): 
     1218        if self._constructed(): 
     1219            self._visible = val 
     1220            if self.Parent: 
     1221                self.Parent.showColumn(self, val) 
     1222        else: 
     1223            self._properties["Visible"] = val 
     1224 
     1225 
    12121226    def _getWidth(self): 
    12131227        idx = self._GridColumnIndex 
     
    12181232        if self.Parent and idx >= 0: 
    12191233            # Make sure the grid is in sync: 
    1220             self.Parent.SetColSize(idx, v) 
     1234            try: 
     1235                self.Parent.SetColSize(idx, v) 
     1236            except: 
     1237                # The grid may still be in the process of being created, so pass. 
     1238                pass 
    12211239        return v 
    12221240 
     
    14131431            are 'Top', 'Center', and 'Bottom'.  (str)""")) 
    14141432 
     1433    Visible = property(_getVisible, _setVisible, None, 
     1434            _("Controls whether the column is shown or not  (bool)")) 
     1435     
    14151436    Width = property(_getWidth, _setWidth, None, 
    14161437            _("Width of this column  (int)") ) 
     
    14571478    DynamicSortable = makeDynamicProperty(Sortable) 
    14581479    DynamicVerticalAlignment = makeDynamicProperty(VerticalAlignment) 
     1480    DynamicVisible = makeDynamicProperty(Visible) 
    14591481    DynamicWidth = makeDynamicProperty(Width) 
    14601482 
     
    16141636        self._headerMouseLeftDown, self._headerMouseRightDown = False, False 
    16151637 
    1616  
    16171638        header.Bind(wx.EVT_LEFT_DCLICK, self.__onWxHeaderMouseLeftDoubleClick) 
    16181639        header.Bind(wx.EVT_LEFT_DOWN, self.__onWxHeaderMouseLeftDown) 
     
    16271648        header.Bind(wx.EVT_IDLE, self.__onWxHeaderIdle) 
    16281649 
    1629  
    16301650        self.bindEvent(dEvents.GridHeaderMouseLeftDown, self._onGridHeaderMouseLeftDown) 
    16311651        self.bindEvent(dEvents.GridHeaderMouseMove, self._onGridHeaderMouseMove) 
     
    16421662        return ret 
    16431663 
     1664 
    16441665    def GetValue(self, row, col): 
    16451666        try: 
     
    16481669            ret = super(dGrid, self).GetValue(row, col) 
    16491670        return ret 
     1671 
    16501672 
    16511673    def SetValue(self, row, col, val): 
     
    16651687        except StandardError, e: 
    16661688            dabo.errorLog.write("Cannot update data set: %s" % e) 
     1689 
    16671690 
    16681691    # Wrapper methods to Dabo-ize these calls. 
     
    16761699            ret = ret.decode(self.Encoding) 
    16771700        return ret 
     1701         
    16781702    def setValue(self, row, col, val): 
    16791703        return self.SetValue(row, col, val) 
     
    16921716        dcol.CustomEditors[row] = edt 
    16931717        #self.SetCellEditor(row, col, edt) 
     1718         
    16941719 
    16951720    def setRendererForCell(self, row, col, rnd): 
     
    17131738        currFocus = self.FindFocus() 
    17141739        currDataField = None 
    1715      
    17161740        # if the current focus is data-aware, we must temporarily remove it's binding 
    17171741        # or the value of the control will flow to other records in the bizobj, but 
     
    17331757            # Used for display purposes when no data is present. 
    17341758            self._addEmptyRows() 
    1735          
    17361759        tbl.setColumns(self.Columns) 
    17371760        tbl.fillTable(force) 
    1738  
    17391761 
    17401762        ## pkm: I've disabled the following block, because setting the focus 
     
    17551777                self.MakeCellVisible(row, col) 
    17561778            self.SetGridCursor(row, col) 
    1757  
    17581779         
    17591780        if currFocus is not None: 
     
    20172038            w = min(w, maxWidth) 
    20182039            colObj.Width = w 
    2019  
    20202040            if persist: 
    20212041                colObj._persist("Width") 
    2022  
    20232042        try: 
    20242043            self.AutoSizeColumn(colNum, setAsMin=False) 
     
    20422061        for col in cols: 
    20432062            sortIndicator = False 
    2044  
    20452063            try: 
    20462064                colObj = self.Columns[col] 
     
    21392157 
    21402158 
     2159    def showColumn(self, col, visible): 
     2160        """If the column is not shown and visible=True, show it. Likewise 
     2161        but opposite if visible=False. 
     2162        """ 
     2163        if isinstance(col, (int, long)): 
     2164            if col < self.ColumnCount: 
     2165                col = self.Columns[col] 
     2166            else: 
     2167                dabo.errorLog.write(_("Invalid column number passed to 'showColumn()'.")) 
     2168                return 
     2169        if visible: 
     2170            if col in self.Columns: 
     2171                # already shown 
     2172                return 
     2173            self.addColumn(col) 
     2174        else: 
     2175            if col in self.Columns: 
     2176                self.removeColumn(col) 
     2177             
     2178         
    21412179    def moveColumn(self, colNum, toNum): 
    21422180        """ Move the column to a new position.""" 
     
    25422580        else: 
    25432581            col.Parent = self 
     2582 
    25442583        if col.Order == -1: 
    25452584            maxOrd = self.maxColOrder() 
     
    25532592            self._syncColumnCount() 
    25542593            self.fillGrid(force=True) 
    2555  
    25562594        try: 
    25572595            ## Set the Width property last, otherwise it won't stick: 
     
    26552693                    wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, 
    26562694                    0, abs(diff)) 
    2657  
    26582695        elif diff > 0: 
    26592696            msg = wx.grid.GridTableMessage(self._Table, 
    26602697                    wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, 
    26612698                    diff) 
    2662  
    26632699        if msg: 
    26642700            self.ProcessTableMessage(msg) 
     
    31283164 
    31293165    def __onWxHeaderContextMenu(self, evt): 
    3130         self.raiseEvent(dEvents.GridHeaderContextMenu, evt) 
     3166        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3167        self.raiseEvent(dEvents.GridHeaderContextMenu, evt, col=col) 
    31313168        evt.Skip() 
    31323169 
     
    31383175 
    31393176    def __onWxHeaderMouseEnter(self, evt): 
    3140         self.raiseEvent(dEvents.GridHeaderMouseEnter, evt) 
     3177        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3178        self.raiseEvent(dEvents.GridHeaderMouseEnter, evt, col=col) 
    31413179        evt.Skip() 
    31423180         
    31433181         
    31443182    def __onWxHeaderMouseLeave(self, evt): 
     3183        col, row = self._getColRowForPosition(evt.GetPosition()) 
    31453184        self._headerMouseLeftDown, self._headerMouseRightDown = False, False 
    3146         self.raiseEvent(dEvents.GridHeaderMouseLeave, evt
     3185        self.raiseEvent(dEvents.GridHeaderMouseLeave, evt, col=col
    31473186        evt.Skip() 
    31483187 
    31493188 
    31503189    def __onWxHeaderMouseLeftDoubleClick(self, evt): 
    3151         self.raiseEvent(dEvents.GridHeaderMouseLeftDoubleClick, evt) 
     3190        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3191        self.raiseEvent(dEvents.GridHeaderMouseLeftDoubleClick, evt, col=col) 
    31523192        evt.Skip() 
    31533193 
    31543194 
    31553195    def __onWxHeaderMouseLeftDown(self, evt): 
    3156         self.raiseEvent(dEvents.GridHeaderMouseLeftDown, evt) 
     3196        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3197        self.raiseEvent(dEvents.GridHeaderMouseLeftDown, evt, col=col) 
    31573198        self._headerMouseLeftDown = True 
    31583199        #evt.Skip() #- don't skip or all the rows will be selected. 
     
    31603201 
    31613202    def __onWxHeaderMouseLeftUp(self, evt): 
    3162         self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt) 
     3203        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3204        self.raiseEvent(dEvents.GridHeaderMouseLeftUp, evt, col=col) 
    31633205        if self._headerMouseLeftDown: 
    31643206            # mouse went down and up in the header: send a click: 
    3165             self.raiseEvent(dEvents.GridHeaderMouseLeftClick, evt
     3207            self.raiseEvent(dEvents.GridHeaderMouseLeftClick, evt, col=col
    31663208            self._headerMouseLeftDown = False 
    31673209        evt.Skip() 
     
    31693211 
    31703212    def __onWxHeaderMouseMotion(self, evt): 
    3171         self.raiseEvent(dEvents.GridHeaderMouseMove, evt) 
     3213        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3214        self.raiseEvent(dEvents.GridHeaderMouseMove, evt, col=col) 
    31723215        evt.Skip() 
    31733216 
    31743217 
    31753218    def __onWxHeaderMouseRightDown(self, evt): 
    3176         self.raiseEvent(dEvents.GridHeaderMouseRightDown, evt) 
     3219        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3220        self.raiseEvent(dEvents.GridHeaderMouseRightDown, evt, col=col) 
    31773221        self._headerMouseRightDown = True 
    31783222        evt.Skip() 
     
    31803224 
    31813225    def __onWxHeaderMouseRightUp(self, evt): 
    3182         self.raiseEvent(dEvents.GridHeaderMouseRightUp, evt) 
     3226        col, row = self._getColRowForPosition(evt.GetPosition()) 
     3227        self.raiseEvent(dEvents.GridHeaderMouseRightUp, evt, col=col) 
    31833228        if self._headerMouseRightDown: 
    31843229            # mouse went down and up in the header: send a click: 
     
    41884233        #self.ShowRowLabels = True 
    41894234 
    4190  
    41914235if __name__ == '__main__': 
    41924236    class TestForm(dabo.ui.dForm): 
  • trunk/dabo/ui/uiwx/dHtmlBox.py

    r2452 r2458  
    3030 
    3131 
    32     def layout(self): 
    33         """ Wrap the wx version of the call, if possible. """ 
    34         self.Layout() 
    35         for child in self.Children: 
    36             try: 
    37                 child.layout() 
    38             except: pass 
    39         try: 
    40             # Call the Dabo version, if present 
    41             self.Sizer.layout() 
    42         except: 
    43             pass 
    44      
    45      
    4632    def setImageURLs(self, val): 
    4733        """Replace standard image file names with 'file:///img.pth' references""" 
     
    6753                break 
    6854        return ret           
    69  
    70  
    71     def _getChildren(self): 
    72         ret = super(dHtmlBox, self)._getChildren() 
    73         return [kid for kid in ret 
    74                 if isinstance(kid, dabo.ui.dPemMixinBase.dPemMixinBase)] 
    75  
    76     def _setChildren(self, val): 
    77         super(dHtmlBox, self)._setChildren(val) 
    7855 
    7956 
     
    11895    def _setSource(self, val): 
    11996        if isinstance(val, types.StringTypes): 
    120             val = self.setImageURLs(val) 
    12197            self._source = val 
    12298            self._page = "" 
     99            val = self.setImageURLs(val) 
    123100            self.SetPage(val) 
    124101 
     
    133110        self.SetScrollRate(rt[0], {True:rt[1], False:0}[val]) 
    134111 
    135  
    136     Children = property(_getChildren, _setChildren, None, 
    137             _("""Child controls of this panel. This excludes the wx-specific 
    138             scroll bars  (list of objects)""")) 
    139112 
    140113    HorizontalScroll = property(_getHorizontalScroll, _setHorizontalScroll, None, 
     
    168141        return """<html> 
    169142        <body bgcolor="#ACAA60"> 
    170         <center><table bgcolor="#455481" width="100%" cellspacing="0" cellpadding="0" border="1"> 
    171         <tr> 
    172             <td align="center"><h1>dHtmlBox</h1></td> 
    173         </tr> 
    174         </table> 
     143        <center> 
     144            <table bgcolor="#455481" width="100%" cellspacing="0" cellpadding="0"  
     145                    border="1"> 
     146                <tr> 
     147                    <td align="center"><h1>dHtmlBox</h1></td> 
     148                </tr> 
     149            </table> 
    175150        </center> 
    176         <p><b>dHtmlBox</b> is a Dabo UI widget object that wraps a WxPython 
    177         html window.  The widget is designed to display html text.  Be careful 
    178         though, because the widget doesn't support advanced functions like Javascript 
    179         parsing. 
    180         </p> 
     151        <p><b><font size="160%" color="#FFFFFF">dHtmlBox</font></b> is a Dabo UI widget that is designed to display html text.  
     152        Be careful, though, because the widget doesn't support advanced functions like  
     153        Javascript parsing.</p> 
     154        <p>It's better to think of it as a way to display <b>rich text</b> using  
     155        <font size="+1" color="#993300">HTML markup</font>, rather 
     156        than a web browser replacement.</p> 
     157         
     158        <p>&nbsp;</p> 
     159        <div align="center"><img src="daboIcon.ico"></div> 
    181160 
    182         <p><b>Dabo</b> is brought to you by <b>Ed Leafe</b>, <b>Paul Mcnett</b>, 
    183         and others in the open source community, Copyright &copy; 2006. 
     161        <p align="center"><b>Dabo</b> is brought to you by <b>Ed Leafe</b>, <b>Paul McNett</b>, 
     162        and others in the open source community. Copyright &copy; 2006 
    184163        </p> 
    185164        </body> 
  • trunk/dabo/ui/uiwx/dPemMixin.py

    r2411 r2458  
    988988        else: 
    989989            kids = self.Children 
     990        if not kids: 
     991            return 
    990992        for kid in kids: 
    991993            ok = hasattr(kid, prop) 
  • trunk/dabo/ui/uiwx/dSpinner.py

    r2390 r2458  
    5555    # Property get/set/del methods follow. Scroll to bottom to see the property 
    5656    # definitions themselves. 
     57    def _getChildren(self): 
     58        return None 
     59     
     60     
    5761    def _getMax(self): 
    5862        return self.GetMax() 
     
    8892 
    8993    # Property definitions: 
     94    Children = property(_getChildren, None, None,  
     95            _("""Need to override this to return None, since the text box and spin 
     96            buttons are not  Dabo children.  (None)""")) 
     97             
     98    Max = property(_getMax, _setMax, None,  
     99            _("Specifies the highest possible value for the spinner. (int)")) 
     100 
    90101    Min = property(_getMin, _setMin, None,  
    91         "Specifies the lowest possible value for the spinner. (int)") 
    92     DynamicMin = makeDynamicProperty(Min) 
    93  
    94     Max = property(_getMax, _setMax, None,  
    95         "Specifies the highest possible value for the spinner. (int)") 
    96     DynamicMax = makeDynamicProperty(Max) 
     102            _("Specifies the lowest possible value for the spinner. (int)")) 
    97103 
    98104    SpinnerWrap = property(_getSpinnerWrap, _setSpinnerWrap, None, 
    99         "Specifies whether the spinner value wraps at the high/low value. (bool)") 
     105            _("Specifies whether the spinner value wraps at the high/low value. (bool)")) 
     106 
     107 
     108    DynamicMax = makeDynamicProperty(Max) 
     109    DynamicMin = makeDynamicProperty(Min) 
    100110    DynamicSpinnerWrap = makeDynamicProperty(SpinnerWrap) 
     111 
    101112 
    102113