dabo Commit
Revision 3447
Date: 2007-10-10 12:02:19 -0700 (Wed, 10 Oct 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3447

Changed:
U   trunk/dabo/ui/uiwx/dForm.py
U   trunk/dabo/ui/uiwx/dGrid.py

Log:
Fixed some bugs relating to incorrect row counts.

Removed the delay around the grid refresh calls.

Stopped the wx-event for grid cell selection under Windows. There may be other 
events that could benefit from this; this was the main one I found.

Added several freeze/thaw calls to grid and form methods.


Diff:
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2007-10-10 15:51:01 UTC (rev 3446)
+++ trunk/dabo/ui/uiwx/dForm.py 2007-10-10 19:02:19 UTC (rev 3447)
@@ -116,9 +116,11 @@
                else:
                        dabo.ui.callAfterInterval(interval, self.__refresh)
        def __refresh(self):
+               self.Freeze()
                super(BaseForm, self).refresh()
-               
-               
+               self.Thaw()
+
+
        def update(self, interval=None):
                """Updates the contained controls with current values from the 
source. 
 
@@ -432,6 +434,7 @@
                        # A False from confirmChanges means "don't proceed"
                        return
 
+               self.Freeze()
                try:
                        busy = dabo.ui.busyInfo(_("Please wait... requerying 
dataset..."))
                        self.stopWatch.Start()
@@ -477,6 +480,7 @@
 
                self.afterRequery()
                self.refresh()
+               self.Thaw()
                return ret
                
 

Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2007-10-10 15:51:01 UTC (rev 3446)
+++ trunk/dabo/ui/uiwx/dGrid.py 2007-10-10 19:02:19 UTC (rev 3447)
@@ -22,6 +22,7 @@
 from dabo.ui import makeDynamicProperty
 
 # from dabo.lib.profilehooks import profile
+# from dabo.dBug import loggit
 
 # See if the new decimal module is present. This is necessary
 # because if running under Python 2.4 or later and using MySQLdb,
@@ -301,11 +302,10 @@
        def IsEmptyCell(self, row, col):
                if row >= self.grid.RowCount:
                        return True
-
                bizobj = self.grid.getBizobj()
                field = self.grid.Columns[col].DataField
                if bizobj:
-                       if field:
+                       if field and (row < bizobj.RowCount):
                                return not bizobj.getFieldVal(field, row)
                        else:
                                return True
@@ -324,16 +324,13 @@
        def GetValue(self, row, col):
                if row >= self.grid.RowCount:
                        return ""
-
                bizobj = self.grid.getBizobj()
                col_obj = self.grid.Columns[col]
                field = col_obj.DataField
-
                dabo.ui.callAfterInterval(200, col_obj._updateDynamicProps)
                dabo.ui.callAfterInterval(200, col_obj._updateCellDynamicProps, 
row)
-
                if bizobj:
-                       if field:
+                       if field and (row < bizobj.RowCount):
                                ret = bizobj.getFieldVal(field, row)
                        else:
                                ret = ""
@@ -342,7 +339,6 @@
                                ret = self.grid.DataSet[row][field]
                        except:
                                ret = ""
-
                if ret is None:
                        ret = self.grid.NoneDisplay
                return ret
@@ -2045,7 +2041,7 @@
                                cap = keyCaption[colKey]
                        except:
                                cap = colKey
-                       col = self.addColumn()
+                       col = self.addColumn(inBatch=True)
                        col.Caption = cap
                        col.DataField = colKey
 
@@ -2795,10 +2791,11 @@
 
 
        def refresh(self, sort=False):
-               if self._inRefreshDelay:
-                       dabo.ui.callAfterInterval(300, self._clearRefreshDelay, 
sort)
-                       return
+#              if self._inRefreshDelay:
+#                      dabo.ui.callAfterInterval(300, self._clearRefreshDelay, 
sort)
+#                      return
                self._inRefreshDelay = True
+               self.Freeze()
                if sort:
                        ref = self._refreshAfterSort
                        self._refreshAfterSort = False
@@ -2808,13 +2805,14 @@
                self._syncColumnCount()
                self._syncRowCount()
                super(dGrid, self).refresh()
-               dabo.ui.callAfterInterval(300, self._clearRefreshDelay, False, 
recall=False)
+#              dabo.ui.callAfterInterval(300, self._clearRefreshDelay, False, 
recall=False)
+               self.Thaw()
 
 
-       def _clearRefreshDelay(self, sort, recall=True):
-               self._inRefreshDelay = False
-               if recall:
-                       self.refresh(sort)
+#      def _clearRefreshDelay(self, sort, recall=True):
+#              self._inRefreshDelay = False
+#              if recall:
+#                      self.refresh(sort)
 
 
        def update(self):
@@ -2842,7 +2840,6 @@
        def _syncColumnCount(self):
                """Sync wx's rendition of column count with our 
self.ColumnCount"""
                msg = None
-               self.BeginBatch()
                wxColumnCount = self.GetNumberCols()
                daboColumnCount = len(self.Columns)
                diff = daboColumnCount - wxColumnCount
@@ -2855,14 +2852,14 @@
                                        wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED,
                                        diff)
                if msg:
+                       self.BeginBatch()
                        self.ProcessTableMessage(msg)
-               self.EndBatch()
+                       dabo.ui.callAfterInterval(50, self._endBatch)
 
 
        def _syncRowCount(self):
                """Sync wx's rendition of row count with our self.RowCount"""
                msg = None
-               self.BeginBatch()
                wxRowCount = self.GetNumberRows()
                daboRowCount = self.RowCount
                diff = daboRowCount - wxRowCount
@@ -2875,10 +2872,16 @@
                                        wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED,
                                        diff)
                if msg:
+                       self.BeginBatch()
                        self.ProcessTableMessage(msg)
-               self.EndBatch()
+                       dabo.ui.callAfterInterval(50, self._endBatch)
 
 
+       def _endBatch(self):
+               for ii in xrange(self.GetBatchCount()):
+                       self.EndBatch()
+
+
        def _getDefaultGridColAttr(self):
                """ Return the GridCellAttr that will be used for all columns 
by default."""
                attr = wx.grid.GridCellAttr()
@@ -3268,7 +3271,6 @@
                if getattr(self, "_inSelect", False):
                        # Avoid recursion
                        return
-
                if self.ColumnCount == 0:
                        # Grid is not fully constructed yet
                        return
@@ -3276,13 +3278,13 @@
                if col.Editable and col.RendererClass == col.boolRendererClass:
                        # user is clicking on a checkbox
                        wx.CallAfter(self.EnableCellEditControl)
-
                self._inSelect = True
                if evt.Selecting():
                        self._updateWxSelection(evt)
                self.raiseEvent(dEvents.GridCellSelected, evt)
                self._lastRow, self._lastCol = evt.GetRow(), evt.GetCol()
-               evt.Skip()
+               if not sys.platform.startswith("win"):
+                       evt.Skip()
                self._inSelect = False
 
 




_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]

Reply via email to