]> git.saurik.com Git - wxWidgets.git/blame - wxPython/wx/lib/mixins/grid.py
reSWIGged
[wxWidgets.git] / wxPython / wx / lib / mixins / grid.py
CommitLineData
d14a1e28
RD
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#----------------------------------------------------------------------------
b881fc78
RD
12# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
13#
14# o 2.5 compatability update.
15# o Untested
16#
1fded56b 17
b881fc78
RD
18import wx
19import wx.grid
d14a1e28
RD
20
21#----------------------------------------------------------------------------
22
23
24class 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
b881fc78
RD
34 self.Bind(wx.EVT_IDLE, self.__OnIdle)
35 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.__OnSelectCell)
d14a1e28
RD
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()
1fded56b 49