custom data type in wx.Grid

Hello,

I've looked at the demo and I see GRID_VALUE_..., but how do I make a
custom value, of say, GRID_VALUE_DATE or GRID_VALUE_MONEY, so that I
can then apply all my formatting, saving, loading, to the data type
and ideally make my life much easier.

To be fair, I haven't looked around THAT much into how this could be
done, but I figured it would be easier to ask rather than to save
myself days of searching.

Thank you,
Eve

You create a custom editor, and possibly a custom renderer. WxPython in Action has some good examples.

Tom

···

On Sun, 2009-06-14 at 16:32 -0700, natchela@gmail.com wrote:


Hello,
I've looked at the demo and I see GRID_VALUE_..., but how do I make a
custom value, of say, GRID_VALUE_DATE or GRID_VALUE_MONEY, so that I
can then apply all my formatting, saving, loading, to the data type
and ideally make my life much easier.
To be fair, I haven't looked around THAT much into how this could be
done, but I figured it would be easier to ask rather than to save
myself days of searching.
Thank you,
Eve

natchela@gmail.com wrote:

Hello,

I've looked at the demo and I see GRID_VALUE_..., but how do I make a
custom value, of say, GRID_VALUE_DATE or GRID_VALUE_MONEY, so that I
can then apply all my formatting, saving, loading, to the data type
and ideally make my life much easier.

To be fair, I haven't looked around THAT much into how this could be
done, but I figured it would be easier to ask rather than to save
myself days of searching.

You can use RegisterDataType, which takes a name for the type, and also the renderer and editor that should be used for that type.

···

--
Robin Dunn
Software Craftsman

Okay, thanks. I will try doing this over the next couple of days.

Well, I managed to get RegisterDataType working, along with the
rendering/editting for those cells, and it worked like a charm.
However, it seems that once I added those, the default drawing for the
rest of the grid stopped and it isn't until I select the cell that it
appears (otherwise, whatever was behind the app. at time of
initialization shows instead.)

I figure I messed up the code somehow and probably not calling
something I should, or have something in the wrong place. I've
compared it to the samples but haven't been able to find anything
remarkably different as well as spent some time experimenting with
moving stuff around.

Don't see how to attach, so, hope this works...
renderers.py: http://www.sendspace.com/file/ea0f2l
editors.py: http://www.sendspace.com/file/0hquv5
gridpanel.py: http://www.sendspace.com/file/sx2vrx

There is no way to attach files in the Google Groups web interface,
but you CAN attach files by sending them by email (I think): wxPython-
users@googlegroups.com

- Mike

···

On Jun 24, 12:52 pm, natchela <natch...@gmail.com> wrote:

Well, I managed to get RegisterDataType working, along with the
rendering/editting for those cells, and it worked like a charm.
However, it seems that once I added those, the default drawing for the
rest of the grid stopped and it isn't until I select the cell that it
appears (otherwise, whatever was behind the app. at time of
initialization shows instead.)

I figure I messed up the code somehow and probably not calling
something I should, or have something in the wrong place. I've
compared it to the samples but haven't been able to find anything
remarkably different as well as spent some time experimenting with
moving stuff around.

Don't see how to attach, so, hope this works...
renderers.py:Free large file hosting. Send big files the easy way!
editors.py:Free large file hosting. Send big files the easy way!
gridpanel.py:Free large file hosting. Send big files the easy way!

Mike Driscoll wrote:

There is no way to attach files in the Google Groups web interface,
but you CAN attach files by sending them by email (I think): wxPython-
users@googlegroups.com

Correct.

···

--
Robin Dunn
Software Craftsman

natchela wrote:

Well, I managed to get RegisterDataType working, along with the
rendering/editting for those cells, and it worked like a charm.
However, it seems that once I added those, the default drawing for the
rest of the grid stopped and it isn't until I select the cell that it
appears (otherwise, whatever was behind the app. at time of
initialization shows instead.)

I figure I messed up the code somehow and probably not calling
something I should, or have something in the wrong place. I've
compared it to the samples but haven't been able to find anything
remarkably different as well as spent some time experimenting with
moving stuff around.

Don't see how to attach, so, hope this works...
renderers.py: Free large file hosting. Send big files the easy way!
editors.py: Free large file hosting. Send big files the easy way!
gridpanel.py: Free large file hosting. Send big files the easy way!

Nothing jumps out at me as wrong. Please make a small runnable sample so someone can take a close look.

http://wiki.wxpython.org/MakingSampleApps

···

--
Robin Dunn
Software Craftsman

Sample made and sent (and still broken). Know in advance that I appreciate your time on this.

-Eve

natchelasampleapp.py (3.74 KB)

···

On Wed, Jun 24, 2009 at 4:39 PM, Robin Dunn robin@alldunn.com wrote:

natchela wrote:

Well, I managed to get RegisterDataType working, along with the

rendering/editting for those cells, and it worked like a charm.

However, it seems that once I added those, the default drawing for the

rest of the grid stopped and it isn’t until I select the cell that it

appears (otherwise, whatever was behind the app. at time of

initialization shows instead.)

I figure I messed up the code somehow and probably not calling

something I should, or have something in the wrong place. I’ve

compared it to the samples but haven’t been able to find anything

remarkably different as well as spent some time experimenting with

moving stuff around.

Don’t see how to attach, so, hope this works…

renderers.py: http://www.sendspace.com/file/ea0f2l

editors.py: http://www.sendspace.com/file/0hquv5

gridpanel.py: http://www.sendspace.com/file/sx2vrx

Nothing jumps out at me as wrong. Please make a small runnable sample

so someone can take a close look.

http://wiki.wxpython.org/MakingSampleApps

Robin Dunn

Software Craftsman

http://wxPython.org

Eve Ragins wrote:

Sample made and sent (and still broken). Know in advance that I appreciate your time on this.

Since you are setting a clipping region you need to get rid of it when done, otherwise any further drawing on the same DC will be clipped to the same region. Call dc.DestroyClippingRegion()

···

--
Robin Dunn
Software Craftsman

Ah. So simple and yet so hard. Many thanks.

···

On Thu, Jun 25, 2009 at 8:03 PM, Robin Dunn robin@alldunn.com wrote:

Eve Ragins wrote:

Sample made and sent (and still broken). Know in advance that I

appreciate your time on this.

Since you are setting a clipping region you need to get rid of it when

done, otherwise any further drawing on the same DC will be clipped to

the same region. Call dc.DestroyClippingRegion()

Robin Dunn

Software Craftsman

http://wxPython.org