#-*-coding:utf-8
#-------------------------------------------------------------------------------#Name: 模块1#Purpose:#
#Author: ankier#
#Created: 14/10/2012#Copyright: (c) ankier 2012#Licence: #-------------------------------------------------------------------------------
importwx, wx.grid as grd#grid column类型
classGridColumnControlKind:
Text="Text"CheckBox= "CheckBox"Colour= "Colour"
#定购的Grid cell color editor
classGridCellColorEditor(grd.PyGridCellEditor):defCreate(self, parent, id, evtHandler):"""Called to create the control, which must derive from wx.Control.
*Must Override*"""self.__Parent =parent
self.__ColorDialog =None
self.__ColorButton = wx.Button(parent, id, "")
self.SetControl(self.__ColorButton)#添加新的event handler, 防止 弹出窗口后, cell 自动editor
newEventHandler =wx._core.EvtHandler()ifevtHandler:
self.__ColorButton.PushEventHandler(newEventHandler)
self.__ColorButton.Bind(wx.EVT_BUTTON, self.OnClick)defOnClick(self, event):
self.__ColorButton.SetFocus()
self.ShowColorDialog()defSetSize(self, rect):"""Called to position/size the edit control within the cell rectangle.
If you don't fill the cell (the rect) then be sure to override
PaintBackground and do something meaningful there."""self.__ColorButton.SetDimensions(rect.x,rect.y,rect.width+2,rect.height+2,wx.SIZE_ALLOW_MINUS_ONE)defClone(self):"""Create a new object which is the copy of this one
*Must Override*"""
returnGridCellColorEditor()defBeginEdit(self, row, col, grid):"""Fetch the value from the table and prepare the edit control
to begin editing. Set the focus to the edit control.
*Must Override*"""self.startValue=grid.GetTable().GetValue(row, col)