]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/mixins/grid.py
Insure suitable choices of path/drive separator on OS/2.
[wxWidgets.git] / wxPython / wx / lib / mixins / grid.py
index a0d0c6ae791b3eb75242659c7ad3ae5a2576b1c4..b6040111b799d57a3eb7c84f021b6f0978be3f4b 100644 (file)
@@ -1,8 +1,43 @@
+#----------------------------------------------------------------------------
+# Name:        wxPython.lib.mixins.grid
+# Purpose:     Helpful mix-in classes for wxGrid
+#
+# Author:      Robin Dunn
+#
+# Created:     5-June-2001
+# RCS-ID:      $Id$
+# Copyright:   (c) 2001 by Total Control Software
+# Licence:     wxWindows license
+#----------------------------------------------------------------------------
 
-"""Renamer stub: provides a way to drop the wx prefix from wxPython objects."""
+from wxPython import wx, grid
+
+#----------------------------------------------------------------------------
+
+
+class wxGridAutoEditMixin:
+    """A mix-in class that automatically enables the grid edit control when
+    a cell is selected.
+
+    If your class hooks EVT_GRID_SELECT_CELL be sure to call event.Skip so
+    this handler will be called too.
+    """
+
+    def __init__(self):
+        self.__enableEdit = 0
+        wx.EVT_IDLE(self, self.__OnIdle)
+        grid.EVT_GRID_SELECT_CELL(self, self.__OnSelectCell)
+
+
+    def __OnIdle(self, evt):
+        if self.__enableEdit:
+            if self.CanEnableCellControl():
+                self.EnableCellEditControl()
+            self.__enableEdit = 0
+        evt.Skip()
+
+
+    def __OnSelectCell(self, evt):
+        self.__enableEdit = 1
+        evt.Skip()
 
-from wx import _rename
-from wxPython.lib.mixins import grid
-_rename(globals(), grid.__dict__, modulename='lib.mixins.grid')
-del grid
-del _rename