Ticket #1138 (new enhancement)

Opened 3 months ago

Last modified 3 months ago

dGrid with dDateTextBox

Reported by: gary Assigned to: somebody
Priority: minor Milestone:
Component: ui Version: 0.8.3
Keywords: dGrid dDateTextBox wx Cc:

Description

This is a grid editor class using the dDateTextBox Control within a dGrid. Only available in wx at the moment.

This was developed on: Platform: GTK Python Version: 2.5.1 on linux2 Dabo Version: Version 0.8.3; Revision ~3849 UI Version: 2.8.7.1 on wxGTK (gtk2)

Attachments

gGridEditors.py (10.0 kB) - added by gary on 01/31/08 15:58:37.
Preliminary Version of Classes for GridDateEditor?
gGridEditors.2.py (10.6 kB) - added by gary on 02/11/08 05:08:35.
Updated to request user response for update if invalid date value exists in field
gGridEditors.3.py (12.8 kB) - added by gary on 02/11/08 08:03:25.
This one is now working. I have modified some of the dDateTextBox to make it less flexible but more consistent in the use of datetime classes.

Change History

01/31/08 15:58:37 changed by gary

  • attachment gGridEditors.py added.

Preliminary Version of Classes for GridDateEditor?

(follow-up: ↓ 3 ) 01/31/08 16:00:11 changed by gary

Comments from Mailing List:

johnf wrote:

On Thursday 31 January 2008 09:10:00 am Paul McNett? wrote:

johnf wrote:

On Thursday 31 January 2008 07:35:59 am Gary Thompson wrote:

Hi All, I hope this is an appropriate place to share this. I've been wanting to have a DateTextBox? as part of a grid column for a long time, to simplify bulk data editing where dates are involved. I have managed to hack something together which does the job, I must warn you that I do not have a lot of programming experience (thank you to those out there whose code I poached in trying to put this together). If there is another way which I missed when trying to resolve this, I would be interested in knowing. Otherwise, here is some code:

Running the code I noticed that typing in 01/32/2008 (Jan 32 2008) caused the date to become 01/31/2008 without warning the user. Shouldn't you warn the user?

IMO the behavior should be to revert back to the prior entry. IOW, if 6/17/2006 was displayed, and the user typed 01/32/2008, the entry would revert back to 6/17/2006. Paul

+1

02/01/08 07:20:50 changed by gary

There seems to be a bug when using this class on a Grid with a DataSource? (bizobj). My application simply exists and there is no error information, I'm working on this when i can.

(in reply to: ↑ 1 ) 02/01/08 07:27:41 changed by gary

Replying to gary:

Comments from Mailing List: johnf wrote:

On Thursday 31 January 2008 09:10:00 am Paul McNett? wrote:

johnf wrote:

On Thursday 31 January 2008 07:35:59 am Gary Thompson wrote:

Hi All, I hope this is an appropriate place to share this. I've been wanting to have a DateTextBox? as part of a grid column for a long time, to simplify bulk data editing where dates are involved. I have managed to hack something together which does the job, I must warn you that I do not have a lot of programming experience (thank you to those out there whose code I poached in trying to put this together). If there is another way which I missed when trying to resolve this, I would be interested in knowing. Otherwise, here is some code:

Running the code I noticed that typing in 01/32/2008 (Jan 32 2008) caused the date to become 01/31/2008 without warning the user. Shouldn't you warn the user?

IMO the behavior should be to revert back to the prior entry. IOW, if 6/17/2006 was displayed, and the user typed 01/32/2008, the entry would revert back to 6/17/2006. Paul

+1

In testing I performed, I found the values to revert on incorrect input. I can't replicate the behaviour above. I did design the code so that when you edit a field which has an invalid date already set, it will reset the date. I can include a pop-up message alerting the user in this case.

02/01/08 15:07:35 changed by gary

I'm not sure how or why this is occurring, but when I use a DataSource? instead of a dataset, I am getting a segmentation fault when the Edit control looses focus. Here is the information from gdb:

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb7c6a6c0 (LWP 6117)] 0xb730991e in wxGridCellEditor::Show () from /usr/lib/libwx_gtk2u_adv-2.8.so.0

I don't know how to debug this any further. If someone is not having this problem, please let me know. I might need to recompile my wx libraries without optimisations or something.

02/11/08 04:37:55 changed by gary

The Crash that I reported earlier appears to have been resolved somewhere. Recent testing has not reproduced the crash and I have updated my system. Here is my current configuration:

Platform: GTK Python Version: 2.5.1 on linux2 Dabo Version: Version 0.8.3; Revision ~3908 UI Version: 2.8.7.1 on wxGTK (gtk2)

02/11/08 04:40:12 changed by gary

Sorry, I missed out the fact that I'm also running now on an AMD64 system (GNU/Linux - Gentoo) whereas previously it was an X86 system, I do not know if this has made a difference either.

I suspect the crash may have simply been a compilation error due to optimizations when I was running on my 32 bit system.

02/11/08 05:08:35 changed by gary

  • attachment gGridEditors.2.py added.

Updated to request user response for update if invalid date value exists in field

02/11/08 05:33:43 changed by gary

The Above attachment does not function as planned, and for some reason key events aren't being sent to the date text box and so keyboard events aren't being registered.

I suspect this has a problem with the creation of the control and will submit a correction when completed.

(follow-up: ↓ 9 ) 02/11/08 07:21:32 changed by gary

I've worked out the problem and when I get a chance I will send an update.

Basically, key events are being sent but the problem is I'm confused with the usage of dDateTextBox. Sometimes I might use a Value of string type and then end up with a date type when I'm reading back (I think it's the Calendar that leaves a date type).

Also, there's the problem of date formatting. I think I prefer a date type as it removes ambiguity for date formats. My next update will include a slightly more modified version of this class.

(in reply to: ↑ 8 ; follow-up: ↓ 10 ) 02/11/08 08:01:45 changed by ed

Replying to gary:

Basically, key events are being sent but the problem is I'm confused with the usage of dDateTextBox. Sometimes I might use a Value of string type and then end up with a date type when I'm reading back (I think it's the Calendar that leaves a date type).

dDateTextBox should only be used with date values. I'm surprised that it works at all with strings.

02/11/08 08:03:25 changed by gary

  • attachment gGridEditors.3.py added.

This one is now working. I have modified some of the dDateTextBox to make it less flexible but more consistent in the use of datetime classes.

(in reply to: ↑ 9 ; follow-up: ↓ 11 ) 02/11/08 08:11:49 changed by gary

Replying to ed:

Replying to gary:

Basically, key events are being sent but the problem is I'm confused with the usage of dDateTextBox. Sometimes I might use a Value of string type and then end up with a date type when I'm reading back (I think it's the Calendar that leaves a date type).

dDateTextBox should only be used with date values. I'm surprised that it works at all with strings.

I found that when using this type of control linked to a Date field of type date, the textbox was populated with a unicode string of the date. When the box is then edited, a date object then populated <object>.Value.

Unfortunately it was some time ago that I worked with this but I remember having problems not being sure if I was getting a unicode string of the date or a date object when working with the dDateTextBox.Value property.

When I get a change I will try and dig up the project I was working on to see more clearly what some of the issues were. I may have just not been using the control properly.

(in reply to: ↑ 10 ) 02/11/08 08:18:08 changed by ed

Replying to gary:

I found that when using this type of control linked to a Date field of type date, the textbox was populated with a unicode string of the date. When the box is then edited, a date object then populated <object>.Value.

This is because the wxPython text control can only deal with strings. We do a lot behind the scene to convert each type to the proper string representation for display and editing, and then convert back to the original type for persistence to its bound object.