wx.grid.GridCellDateRenderer

Hello,
I’m just starting with python programming and wxPython and I’d appreciate a little help from the experts.

I have created a grid for which I am trying to define an attribute for the various data types.
I didn’t encounter any problem with all the other data types except for the DATE.

attrD = wx.grid.GridCellAttr()
attrD.SetRenderer(wx.grid.GridCellDateRenderer())
attrD.SetEditor(wx.grid.GridCellDateEditor())

The error message is:
AttributeError: ‘module’ object has no attribute ‘GridCellDateRenderer’

I’ve seen GridCellDateRenderer in various wxPython documentation. I’ve also search the internet on how to create a renderer for a cell in the grid containing a date value but have been unable to find the answer.

Will greatly appreciate any help.

Thank you.

What version of wxPython are you using?

On Python 3.8.5 + wxPython 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5 on Linux Mint 20.1, wx.grid.GridCellDateRenderer is available:

import wx
import wx.grid

renderer = wx.grid.GridCellDateRenderer()
print(renderer)

This outputs:
<wx._grid.GridCellDateRenderer object at 0x7f261e67f1f0>

The wxPython documentation says “New in version 4.1/wxWidgets-3.1.3”.

When I entered the command you gave, I get the same error message. AttributeError: ‘module’ object has no attribute ‘GridCellDateRenderer’

I’m using Python 2.7.15.
When I check wxPython version via wx.version(), I get 4.0.3 msw (phoenix) wxWidgets 3.0.5

Richard,

Python 2.7 is just old as 10 years …
If you are not blocked by a lib upgrade to Python 3, you will have a better support and update easily with pip command (or other) to last wxPython suitable for your environment.

If for some reason you can’t upgrade to wxPython 4.1 or later, you could try to derive your own GridCellDateRenderer class from the abstract wx.grid.GridCellRenderer class.

I can’t upgrade to Python 3 because I’m using dbf from dbfpy which has no version 3 yet (I’m converting applications written in VFP to Python).

I will look into your other suggestion.

Thank you very much for your reply. I really appreciate it.

I have moved several VFP apps to python3. First I don’t actually use dbf’s - I either convert the table to Postgresql or sqlite. I transfer the data using dbf_light · PyPI. There are also some free ETL’s available.

I also use dabo (version 3 - https://github.com/dabodev/dabo.git then use branch dabo3). Dabo uses the same thinking that VFP - there are differences but overall the thinking works. Dabo also uses Postgresql or sqlite. BTW dabo provides the UI and the way to attach data to the widgets.

I am converting an integrated system with several applications (finance, payroll, inventory, sales, etc.) I am not able to convert them all at the same time and since they’re all integrated, I need dbfpy for the python programs to access dbf files. I have already converted several VFP forms to wxPython without problem until I needed to create a VFP table that has cells containing dates.

I looked up dabo and found it to be promising. However, there doesn’t seem to be enough documentation on it for a newbie like me who has barely two weeks of python experience. I will try it later when I don’t have a deadline.

Thanks for the reply.