create TextCtrl or DatePickerCtrl depending of data type

I have a grid with a number of columns,

for each column corresponds to a data type that can

contain (integer, date).

My idea is to define a column for each

editor that can be a wx.TextCtrl or wx.DatePickerCtrl

depending on the data defined for that column.

Will textctrl used for data type string, integer, etc.,

will DatePickerCtrl be used for data type date.

To do this I’m using the method of Create

pyGridCellEditor.

Someone can tell me where I’m going to take

information on the column of the grid on which

Create method is being run?

My assumption is that

information about data types is “tipi”(list) the

whose length is the number of columns

grid.

Follow Pseudo encoding:

tipi = [‘date’,‘integer’,…,‘string’]

class CreateCellEditorPy(wx.grid.PyGridCellEditor):

def init(self,frame,tipi):

wx.grid.PyGridCellEditor.init(self)

self.frame = frame

self.tipi = tipi

self.countComma = 0

def Create(self, parent, id, evtHandler):

if tipi[??col] == ‘date’ \

or tipi[??col] == ‘DATE’:

self._tc = wx.DatePickerCtrl(parent, size=(-1,-1),

style = wx.DP_DROPDOWN

wx.DP_SHOWCENTURY

wx.DP_ALLOWNONE )

else:

self._tc = wx.TextCtrl(parent, id, “”,style=wx.TE_PROCESS_TAB)

self._tc.SetInsertionPoint(0)

self.SetControl(self._tc)

if evtHandler:

self._tc.PushEventHandler(evtHandler)

#self._tc.Bind(wx.EVT_CHAR, self.OnChar)

···


Fabio Spadaro

www.fabiospadaro.com

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

You should create two different cell editor classes, one that uses a textctrl and one that uses a date control. Then you can either assign an instance of the correct kind to each column with SetColAttr as part of the attributes for that column, or if you are using a custom table that reports the data type for cells then you can register the editor types to be used for particular types with RegisterDataType.

···

On 4/23/10 2:44 AM, Fabio Spadaro wrote:

I have a grid with a number of columns,
for each column corresponds to a data type that can
contain (integer, date).

My idea is to define a column for each
editor that can be a wx.TextCtrl or wx.DatePickerCtrl
depending on the data defined for that column.
Will textctrl used for data type string, integer, etc.,
will DatePickerCtrl be used for data type date.
To do this I'm using the method of Create
pyGridCellEditor.

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en