2003-11-12 16:34:20 -05:00
|
|
|
#----------------------------------------------------------------------------
|
2005-12-30 18:02:03 -05:00
|
|
|
# Name: wx.lib.mixins.grid
|
2003-12-22 14:09:54 -05:00
|
|
|
# Purpose: Helpful mix-in classes for wx.Grid
|
2003-11-12 16:34:20 -05:00
|
|
|
#
|
|
|
|
# Author: Robin Dunn
|
|
|
|
#
|
|
|
|
# Created: 5-June-2001
|
|
|
|
# RCS-ID: $Id$
|
|
|
|
# Copyright: (c) 2001 by Total Control Software
|
|
|
|
# Licence: wxWindows license
|
|
|
|
#----------------------------------------------------------------------------
|
2003-12-16 19:34:40 -05:00
|
|
|
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o 2.5 compatability update.
|
|
|
|
# o Untested
|
|
|
|
#
|
2003-12-22 14:09:54 -05:00
|
|
|
# 12/21/2003 - Jeff Grimmett (grimmtooth@softhome.net)
|
|
|
|
#
|
|
|
|
# o wxGridAutoEditMixin -> GridAutoEditMixin
|
|
|
|
#
|
2003-07-02 19:13:10 -04:00
|
|
|
|
2003-12-16 19:34:40 -05:00
|
|
|
import wx
|
|
|
|
import wx.grid
|
2003-11-12 16:34:20 -05:00
|
|
|
|
|
|
|
#----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2003-12-22 14:09:54 -05:00
|
|
|
class GridAutoEditMixin:
|
2003-11-12 16:34:20 -05:00
|
|
|
"""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):
|
2003-12-16 19:34:40 -05:00
|
|
|
self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.__OnSelectCell)
|
2003-11-12 16:34:20 -05:00
|
|
|
|
|
|
|
|
2005-12-30 18:02:03 -05:00
|
|
|
def __DoEnableEdit(self):
|
|
|
|
if self.CanEnableCellControl():
|
|
|
|
self.EnableCellEditControl()
|
2003-11-12 16:34:20 -05:00
|
|
|
|
|
|
|
|
|
|
|
def __OnSelectCell(self, evt):
|
2005-12-30 18:02:03 -05:00
|
|
|
wx.CallAfter(self.__DoEnableEdit)
|
2003-11-12 16:34:20 -05:00
|
|
|
evt.Skip()
|
2003-07-02 19:13:10 -04:00
|
|
|
|