]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/mixins/grid.py
Added wx.lib.gestures module from Daniel Pozmanter which supports
[wxWidgets.git] / wxPython / wx / lib / mixins / grid.py
1 #----------------------------------------------------------------------------
2 # Name: wxPython.lib.mixins.grid
3 # Purpose: Helpful mix-in classes for wx.Grid
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 # 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
18 #
19 # o wxGridAutoEditMixin -> GridAutoEditMixin
20 #
21
22 import wx
23 import wx.grid
24
25 #----------------------------------------------------------------------------
26
27
28 class GridAutoEditMixin:
29 """A mix-in class that automatically enables the grid edit control when
30 a cell is selected.
31
32 If your class hooks EVT_GRID_SELECT_CELL be sure to call event.Skip so
33 this handler will be called too.
34 """
35
36 def __init__(self):
37 self.__enableEdit = 0
38 self.Bind(wx.EVT_IDLE, self.__OnIdle)
39 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.__OnSelectCell)
40
41
42 def __OnIdle(self, evt):
43 if self.__enableEdit:
44 if self.CanEnableCellControl():
45 self.EnableCellEditControl()
46 self.__enableEdit = 0
47 evt.Skip()
48
49
50 def __OnSelectCell(self, evt):
51 self.__enableEdit = 1
52 evt.Skip()
53