Cant create wx.DateTime

Hi,

I am trying to generate a wx.DateTime object so I can SetValue into a
wx.DatePickerCtrl but am having a struggle. As demo code I tried

            dt_inst = wx.DateTime()
            dt_inst.SetYear(2012)
            dt_inst.SetMonth(2)
            dt_inst.SetDay(1)
            dt_inst.SetHMS(0)

But keep getting

Traceback (most recent call last):
  File "C:\Program Files\FX Hammer\core\gui.py", line 434, in __editSelectedClea
r
    EditExistingClear(self, self.fx_hammer_dir, record)
  File "C:\Program Files\FX Hammer\core\gui.py", line 1314, in __init__
    ClearLib.__init__(self, parent, fx_hammer_dir, 'Edit Existing Clear')
  File "C:\Program Files\FX Hammer\core\gui.py", line 669, in __init__
    self.initForm()
  File "C:\Program Files\FX Hammer\core\gui.py", line 1323, in initForm
    self.populateForm(self.record)
  File "C:\Program Files\FX Hammer\core\gui.py", line 1037, in populateForm
    dt_inst.SetYear(2012)
  File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_misc.py", line 3677
, in SetYear
    return _misc_.DateTime_SetYear(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "IsValid()" failed at ..\..\include\wx/
datetime.h(1688) in wxDateTime::GetTicks(): invalid wxDateTime

I have tried year as 2012, 12 etc, it is supposed to be an integer and
I am a little confused. Also assuming my mistake is something obvious
(I am good at that :)), is there a more elegant way of instantiating
DateTime with a required date ?, was hoping to do this vial __init__
but nothing documented ?

Cheers

Dave

···

--

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

Hi Dave,

···

On 28/04/2012 10:57, dave selby wrote:

Hi,

I am trying to generate a wx.DateTime object so I can SetValue into a
wx.DatePickerCtrl but am having a struggle. As demo code I tried

             dt_inst = wx.DateTime()
             dt_inst.SetYear(2012)
             dt_inst.SetMonth(2)
             dt_inst.SetDay(1)
             dt_inst.SetHMS(0)

use e.g.
dt_inst = wx.DateTime().Today()
to initialize it and then you can do SetYear etc., it looks like you have to have a valid instance of wx.DateTime before you can use these other 'Set" methods.

Werner

OK thanks, that works,

Cheers

Dave

···

On 28 April 2012 10:24, Werner <werner.bruhin@sfr.fr> wrote:

Hi Dave,

On 28/04/2012 10:57, dave selby wrote:

Hi,

I am trying to generate a wx.DateTime object so I can SetValue into a
wx.DatePickerCtrl but am having a struggle. As demo code I tried

        dt\_inst = wx\.DateTime\(\)
        dt\_inst\.SetYear\(2012\)
        dt\_inst\.SetMonth\(2\)
        dt\_inst\.SetDay\(1\)
        dt\_inst\.SetHMS\(0\)

use e.g.
dt_inst = wx.DateTime().Today()
to initialize it and then you can do SetYear etc., it looks like you have to
have a valid instance of wx.DateTime before you can use these other 'Set"
methods.

Werner

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

--

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

That is correct.

···

On 4/28/12 2:24 AM, Werner wrote:

Hi Dave,

On 28/04/2012 10:57, dave selby wrote:

Hi,

I am trying to generate a wx.DateTime object so I can SetValue into a
wx.DatePickerCtrl but am having a struggle. As demo code I tried

dt_inst = wx.DateTime()
dt_inst.SetYear(2012)
dt_inst.SetMonth(2)
dt_inst.SetDay(1)
dt_inst.SetHMS(0)

use e.g.
dt_inst = wx.DateTime().Today()
to initialize it and then you can do SetYear etc., it looks like you
have to have a valid instance of wx.DateTime before you can use these
other 'Set" methods.

--
Robin Dunn
Software Craftsman