]> git.saurik.com Git - wxWidgets.git/blame - wxPython/wx/lib/mixins/grid.py
flicker reduction for gtk2
[wxWidgets.git] / wxPython / wx / lib / mixins / grid.py
CommitLineData
d14a1e28
RD
1#----------------------------------------------------------------------------
2# Name: wxPython.lib.mixins.grid
d4b73b1b 3# Purpose: Helpful mix-in classes for wx.Grid
d14a1e28
RD
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#
d4b73b1b
RD
17# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
18#
19# o wxGridAutoEditMixin -> GridAutoEditMixin
20#
1fded56b 21
b881fc78
RD
22import wx
23import wx.grid
d14a1e28
RD
24
25#----------------------------------------------------------------------------
26
27
d4b73b1b 28class GridAutoEditMixin:
d14a1e28
RD
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
b881fc78
RD
38 self.Bind(wx.EVT_IDLE, self.__OnIdle)
39 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.__OnSelectCell)
d14a1e28
RD
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()
1fded56b 53