Hi - sorry to trouble you all again
I am working on an editor to edit data from relational database
tables. As you may know it is quite permissible to have a value of
'NULL' as a value in a database field. Normally this equates quite
well to the Python 'None'.
But this creates problems when you try to load up a date field in
wxPython. For example I may have someone's birthdate as None -
because the database does not know it. Then someone who does know the
birthdate may want to use my editor to enter a valid date.
I could (I suppose) just default the date picker to some date like
1/1/1900, and then interpret that as None if someone does no edit, and
interpret any data but 1/1/1900 as a real date. But that seems ugly
and has some drawbacks. Same for numeric values too. How do you
handle 'None'/'NULL' when you want to load up a field designed to
hold numbers like a maskedNumCtrl? Zero will not do as a default,
because there is a difference between 'this field has a value of zero'
and 'I do not know what the value of this field is'. Just not calling
SetValue for 'NULL's does not seem a great idea either as you just
0.00 for today's date.
Anyone thought of a neat trick for this?
Kind regards
Phil
Sorry I meant 0.00 OR today's date (ie for NumCtrl or Date controls),
not FOR
phil
···
On Dec 4, 10:09 am, Philip Ellis <philipjel...@gmail.com> wrote:
Hi - sorry to trouble you all again
I am working on an editor to edit data from relational database
tables. As you may know it is quite permissible to have a value of
'NULL' as a value in a database field. Normally this equates quite
well to the Python 'None'.
But this creates problems when you try to load up a date field in
wxPython. For example I may have someone's birthdate as None -
because the database does not know it. Then someone who does know the
birthdate may want to use my editor to enter a valid date.
I could (I suppose) just default the date picker to some date like
1/1/1900, and then interpret that as None if someone does no edit, and
interpret any data but 1/1/1900 as a real date. But that seems ugly
and has some drawbacks. Same for numeric values too. How do you
handle 'None'/'NULL' when you want to load up a field designed to
hold numbers like a maskedNumCtrl? Zero will not do as a default,
because there is a difference between 'this field has a value of zero'
and 'I do not know what the value of this field is'. Just not calling
SetValue for 'NULL's does not seem a great idea either as you just
0.00 for today's date.
Anyone thought of a neat trick for this?
Kind regards
Phil
I don't see how. If you send an empty string to a Date Control or a
NumCtrl it will give an error. Like this.
Traceback (most recent call last):
File "Q:\Database Project\Python\WX\paneltest.py", line 59, in
<module>
app = MyApp(0)
File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 7978, in __init__
self._BootstrapApp()
File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 7552, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "Q:\Database Project\Python\WX\paneltest.py", line 55, in
OnInit
frame = MyFrame(None, -1, 'borders.py')
File "Q:\Database Project\Python\WX\paneltest.py", line 35, in
__init__
self.dpc.SetValue("")
File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx
\_controls.py", line 6455, in SetValue
return _controls_.DatePickerCtrlBase_SetValue(*args, **kwargs)
TypeError: in method 'DatePickerCtrlBase_SetValue', expected argument
2 of type 'wxDateTime const &'
···
On Dec 4, 10:13 am, Cody Precord <codyprec...@gmail.com> wrote:
Hi,
On Fri, Dec 4, 2009 at 10:09 AM, Philip Ellis <philipjel...@gmail.com> wrote:
> Anyone thought of a neat trick for this?
Cant you just display an empty string (i.e no value in the control)
when its NULL
Cody