dabo Commit
Revision 6657
Date: 2011-07-04 04:49:08 -0700 (Mon, 04 Jul 2011)
Author: Ed
Trac: http://trac.dabodev.com/changeset/6657
Changed:
U trunk/dabo/ui/uiwx/dGrid.py
Log:
Changed the repeated call to _getDaboVisibleCols() to a grid attribute that
only gets calculated when the _syncColumnCount() method is called. This seems
to fix the problem with grids and Python 2.7 on my systems; please verify that
grids work with 2.7 on your systems.
Changed the header context menu so that if ResizableColumns is False, the
options to autosize the column is not available.
Changed the background color of column 1 in the demo code to something a little
less ugly.
Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2011-07-04 11:45:02 UTC (rev 6656)
+++ trunk/dabo/ui/uiwx/dGrid.py 2011-07-04 11:49:08 UTC (rev 6657)
@@ -553,7 +553,7 @@
@dabo.ui.deadCheck
def _updateCellDynamicProps(self, row):
dabo.ui.callAfterInterval(200,
self._updateCellDynamicProps_delayed, row)
-
+
@dabo.ui.deadCheck
def _updateCellDynamicProps_delayed(self, row):
kwargs = {"row": row}
@@ -1769,6 +1769,8 @@
self._refreshAfterSort = True
# Local count of rows in the data table
self._tableRows = 0
+ # List of visible columns
+ self._daboVisibleColumns = []
# When user selects new row, does the form have responsibility
for making the change?
self._mediateRowNumberThroughForm = True
@@ -2168,16 +2170,16 @@
dabo.ui.callAfterInterval(200, self.refresh)
- def _getDaboVisibleCols(self):
+ def _updateDaboVisibleColumns(self):
try:
- return [e[0] for e in enumerate(self._columns) if
e[1].Visible]
+ self._daboVisibleColumns = [e[0] for e in
enumerate(self._columns) if e[1].Visible]
except wx._core.PyAssertionError, e:
# Can happen when an editor is active and columns resize
- ret = []
+ vis = []
for pos, col in enumerate(self._columns):
if col.Visible:
- ret.append(pos)
- return ret
+ vis.append(pos)
+ self._daboVisibleColumns = vis
def _convertWxColNumToDaboColNum(self, wxCol):
@@ -2188,7 +2190,7 @@
Returns None if there is no corresponding dabo column.
"""
try:
- return self._getDaboVisibleCols()[wxCol]
+ return self._daboVisibleColumns[wxCol]
except IndexError:
return None
@@ -2200,10 +2202,8 @@
Returns None if there is no corresponding wx column.
"""
-
- daboVis = self._getDaboVisibleCols()
try:
- return daboVis.index(daboCol)
+ return self._daboVisibleColumns.index(daboCol)
except ValueError:
return None
@@ -2720,7 +2720,6 @@
dabo.log.error(_("Invalid column number passed
to 'showColumn()'."))
return
col._visible = visible
-
self._syncColumnCount()
self.refresh()
@@ -3357,6 +3356,9 @@
self.ProcessTableMessage(msg)
self.EndBatch()
+ # Update the visible columns attribute
+ self._updateDaboVisibleColumns()
+
# We need to adjust the Width of visible columns here, in case
any
# columns have Visible = False.
for daboCol, colObj in enumerate(self._columns):
@@ -3556,10 +3558,11 @@
def _autosizeAllColumns(evt):
self.autoSizeCol("All")
- menu.append(_("&Autosize Column"), OnHit=_autosizeColumn,
- help=_("Autosize the column based on the data
in the column."))
- menu.append(_("&Autosize All Columns"),
OnHit=_autosizeAllColumns,
- help=_("Autosize all columns in the grid."))
+ if self.ResizableColumns:
+ menu.append(_("&Autosize Column"),
OnHit=_autosizeColumn,
+ help=_("Autosize the column based on
the data in the column."))
+ menu.append(_("&Autosize All Columns"),
OnHit=_autosizeAllColumns,
+ help=_("Autosize all columns in the
grid."))
menu = self.fillHeaderContextMenu(menu)
@@ -5169,7 +5172,7 @@
self.addColumn(col)
col.HeaderFontItalic = True
- col.HeaderBackColor = "orange"
+ col.HeaderBackColor = "peachpuff"
col.HeaderVerticalAlignment = "Top"
col.HeaderHorizontalAlignment = "Left"
_______________________________________________
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]