]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/mixins/grid.py
Fixed a very weird typo
[wxWidgets.git] / wxPython / wx / lib / mixins / grid.py
1 #----------------------------------------------------------------------------
2 # Name: wxPython.lib.mixins.grid
3 # Purpose: Helpful mix-in classes for wxGrid
4 #
5 # Author: Robin Dunn
6 #
7 # Created: 5-June-2001
8 # RCS-ID: $Id$
9 # Copyright: (c) 2001 by Total Control Software
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------------
12 # 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
13 #
14 # o 2.5 compatability update.
15 # o Untested
16 #
17
18 import wx
19 import wx.grid
20
21 #----------------------------------------------------------------------------
22
23
24 class wxGridAutoEditMixin:
25 """A mix-in class that automatically enables the grid edit control when
26 a cell is selected.
27
28 If your class hooks EVT_GRID_SELECT_CELL be sure to call event.Skip so
29 this handler will be called too.
30 """
31
32 def __init__(self):
33 self.__enableEdit = 0
34 self.Bind(wx.EVT_IDLE, self.__OnIdle)
35 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.__OnSelectCell)
36
37
38 def __OnIdle(self, evt):
39 if self.__enableEdit:
40 if self.CanEnableCellControl():
41 self.EnableCellEditControl()
42 self.__enableEdit = 0
43 evt.Skip()
44
45
46 def __OnSelectCell(self, evt):
47 self.__enableEdit = 1
48 evt.Skip()
49