Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxPython - DatePickerCtrl seems to ignore SetValue()

I'm trying to pre-populate a wxPython DatePicker with a value using the following code:

month, day, year = runData[2][0:8].split('/')
displayDate = wx.DateTimeFromDMY(int(day), int(month) - 1, int(year))
self.datePicker.SetValue(displayDate)

Here are the printed values:

  • runData[2] = 12/16/09 00:00
  • month, day, year = 12 16 09
  • displayDate = 12/16/09 00:00:00

But, datePicker always shows today's date instead.

Any ideas?

I'm using Python 2.6.4 with wxPython 2.8.10.1 on Windows 7.

Thanks.


Update 20/12/09 16:30:

When I try and process the information from the DatePickerCtrl with the problem, I get the following error:

Traceback (most recent call last):
  File "test.py", line 1120, in onOk
    dateLong = self.datePicker.GetValue()
  File "c:\python26\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line
6465, in GetValue
    return _controls_.DatePickerCtrlBase_GetValue(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "m_date.IsValid() == dt.IsValid() && (!
dt.IsValid() || dt == m_date)" failed at ..\..\src\msw\datectrl.cpp(278) in wxDa
tePickerCtrl::GetValue(): bug in wxDatePickerCtrl: m_date not in sync

Am I missing something?

like image 934
David A Avatar asked Nov 05 '22 18:11

David A


1 Answers

Have you tried making year 2009 instead of 9?

like image 88
FogleBird Avatar answered Nov 12 '22 20:11

FogleBird