Changeset 2458
- Timestamp:
- 11/15/06 16:54:27 (2 years ago)
- Files:
-
- trunk/dabo/ui/uiwx/dGrid.py (modified) (27 diffs)
- trunk/dabo/ui/uiwx/dHtmlBox.py (modified) (5 diffs)
- trunk/dabo/ui/uiwx/dPemMixin.py (modified) (1 diff)
- trunk/dabo/ui/uiwx/dSpinner.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/ui/uiwx/dGrid.py
r2415 r2458 433 433 # Do text columns wrap their long text? 434 434 self._wordWrap = False 435 # Is the column shown? 436 self._visible = True 435 437 436 438 self._beforeInit() … … 1210 1212 1211 1213 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 1212 1226 def _getWidth(self): 1213 1227 idx = self._GridColumnIndex … … 1218 1232 if self.Parent and idx >= 0: 1219 1233 # 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 1221 1239 return v 1222 1240 … … 1413 1431 are 'Top', 'Center', and 'Bottom'. (str)""")) 1414 1432 1433 Visible = property(_getVisible, _setVisible, None, 1434 _("Controls whether the column is shown or not (bool)")) 1435 1415 1436 Width = property(_getWidth, _setWidth, None, 1416 1437 _("Width of this column (int)") ) … … 1457 1478 DynamicSortable = makeDynamicProperty(Sortable) 1458 1479 DynamicVerticalAlignment = makeDynamicProperty(VerticalAlignment) 1480 DynamicVisible = makeDynamicProperty(Visible) 1459 1481 DynamicWidth = makeDynamicProperty(Width) 1460 1482 … … 1614 1636 self._headerMouseLeftDown, self._headerMouseRightDown = False, False 1615 1637 1616 1617 1638 header.Bind(wx.EVT_LEFT_DCLICK, self.__onWxHeaderMouseLeftDoubleClick) 1618 1639 header.Bind(wx.EVT_LEFT_DOWN, self.__onWxHeaderMouseLeftDown) … … 1627 1648 header.Bind(wx.EVT_IDLE, self.__onWxHeaderIdle) 1628 1649 1629 1630 1650 self.bindEvent(dEvents.GridHeaderMouseLeftDown, self._onGridHeaderMouseLeftDown) 1631 1651 self.bindEvent(dEvents.GridHeaderMouseMove, self._onGridHeaderMouseMove) … … 1642 1662 return ret 1643 1663 1664 1644 1665 def GetValue(self, row, col): 1645 1666 try: … … 1648 1669 ret = super(dGrid, self).GetValue(row, col) 1649 1670 return ret 1671 1650 1672 1651 1673 def SetValue(self, row, col, val): … … 1665 1687 except StandardError, e: 1666 1688 dabo.errorLog.write("Cannot update data set: %s" % e) 1689 1667 1690 1668 1691 # Wrapper methods to Dabo-ize these calls. … … 1676 1699 ret = ret.decode(self.Encoding) 1677 1700 return ret 1701 1678 1702 def setValue(self, row, col, val): 1679 1703 return self.SetValue(row, col, val) … … 1692 1716 dcol.CustomEditors[row] = edt 1693 1717 #self.SetCellEditor(row, col, edt) 1718 1694 1719 1695 1720 def setRendererForCell(self, row, col, rnd): … … 1713 1738 currFocus = self.FindFocus() 1714 1739 currDataField = None 1715 1716 1740 # if the current focus is data-aware, we must temporarily remove it's binding 1717 1741 # or the value of the control will flow to other records in the bizobj, but … … 1733 1757 # Used for display purposes when no data is present. 1734 1758 self._addEmptyRows() 1735 1736 1759 tbl.setColumns(self.Columns) 1737 1760 tbl.fillTable(force) 1738 1739 1761 1740 1762 ## pkm: I've disabled the following block, because setting the focus … … 1755 1777 self.MakeCellVisible(row, col) 1756 1778 self.SetGridCursor(row, col) 1757 1758 1779 1759 1780 if currFocus is not None: … … 2017 2038 w = min(w, maxWidth) 2018 2039 colObj.Width = w 2019 2020 2040 if persist: 2021 2041 colObj._persist("Width") 2022 2023 2042 try: 2024 2043 self.AutoSizeColumn(colNum, setAsMin=False) … … 2042 2061 for col in cols: 2043 2062 sortIndicator = False 2044 2045 2063 try: 2046 2064 colObj = self.Columns[col] … … 2139 2157 2140 2158 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 2141 2179 def moveColumn(self, colNum, toNum): 2142 2180 """ Move the column to a new position.""" … … 2542 2580 else: 2543 2581 col.Parent = self 2582 2544 2583 if col.Order == -1: 2545 2584 maxOrd = self.maxColOrder() … … 2553 2592 self._syncColumnCount() 2554 2593 self.fillGrid(force=True) 2555 2556 2594 try: 2557 2595 ## Set the Width property last, otherwise it won't stick: … … 2655 2693 wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, 2656 2694 0, abs(diff)) 2657 2658 2695 elif diff > 0: 2659 2696 msg = wx.grid.GridTableMessage(self._Table, 2660 2697 wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, 2661 2698 diff) 2662 2663 2699 if msg: 2664 2700 self.ProcessTableMessage(msg) … … 3128 3164 3129 3165 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) 3131 3168 evt.Skip() 3132 3169 … … 3138 3175 3139 3176 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) 3141 3179 evt.Skip() 3142 3180 3143 3181 3144 3182 def __onWxHeaderMouseLeave(self, evt): 3183 col, row = self._getColRowForPosition(evt.GetPosition()) 3145 3184 self._headerMouseLeftDown, self._headerMouseRightDown = False, False 3146 self.raiseEvent(dEvents.GridHeaderMouseLeave, evt )3185 self.raiseEvent(dEvents.GridHeaderMouseLeave, evt, col=col) 3147 3186 evt.Skip() 3148 3187 3149 3188 3150 3189 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) 3152 3192 evt.Skip() 3153 3193 3154 3194 3155 3195 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) 3157 3198 self._headerMouseLeftDown = True 3158 3199 #evt.Skip() #- don't skip or all the rows will be selected. … … 3160 3201 3161 3202 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) 3163 3205 if self._headerMouseLeftDown: 3164 3206 # 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) 3166 3208 self._headerMouseLeftDown = False 3167 3209 evt.Skip() … … 3169 3211 3170 3212 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) 3172 3215 evt.Skip() 3173 3216 3174 3217 3175 3218 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) 3177 3221 self._headerMouseRightDown = True 3178 3222 evt.Skip() … … 3180 3224 3181 3225 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) 3183 3228 if self._headerMouseRightDown: 3184 3229 # mouse went down and up in the header: send a click: … … 4188 4233 #self.ShowRowLabels = True 4189 4234 4190 4191 4235 if __name__ == '__main__': 4192 4236 class TestForm(dabo.ui.dForm): trunk/dabo/ui/uiwx/dHtmlBox.py
r2452 r2458 30 30 31 31 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: pass39 try:40 # Call the Dabo version, if present41 self.Sizer.layout()42 except:43 pass44 45 46 32 def setImageURLs(self, val): 47 33 """Replace standard image file names with 'file:///img.pth' references""" … … 67 53 break 68 54 return ret 69 70 71 def _getChildren(self):72 ret = super(dHtmlBox, self)._getChildren()73 return [kid for kid in ret74 if isinstance(kid, dabo.ui.dPemMixinBase.dPemMixinBase)]75 76 def _setChildren(self, val):77 super(dHtmlBox, self)._setChildren(val)78 55 79 56 … … 118 95 def _setSource(self, val): 119 96 if isinstance(val, types.StringTypes): 120 val = self.setImageURLs(val)121 97 self._source = val 122 98 self._page = "" 99 val = self.setImageURLs(val) 123 100 self.SetPage(val) 124 101 … … 133 110 self.SetScrollRate(rt[0], {True:rt[1], False:0}[val]) 134 111 135 136 Children = property(_getChildren, _setChildren, None,137 _("""Child controls of this panel. This excludes the wx-specific138 scroll bars (list of objects)"""))139 112 140 113 HorizontalScroll = property(_getHorizontalScroll, _setHorizontalScroll, None, … … 168 141 return """<html> 169 142 <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> 175 150 </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> </p> 159 <div align="center"><img src="daboIcon.ico"></div> 181 160 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 © 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 © 2006 184 163 </p> 185 164 </body> trunk/dabo/ui/uiwx/dPemMixin.py
r2411 r2458 988 988 else: 989 989 kids = self.Children 990 if not kids: 991 return 990 992 for kid in kids: 991 993 ok = hasattr(kid, prop) trunk/dabo/ui/uiwx/dSpinner.py
r2390 r2458 55 55 # Property get/set/del methods follow. Scroll to bottom to see the property 56 56 # definitions themselves. 57 def _getChildren(self): 58 return None 59 60 57 61 def _getMax(self): 58 62 return self.GetMax() … … 88 92 89 93 # 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 90 101 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)")) 97 103 98 104 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) 100 110 DynamicSpinnerWrap = makeDynamicProperty(SpinnerWrap) 111 101 112 102 113
