wxPython - DatePickerCtrl 似乎忽略了 SetValue()

Dav*_*d A 5 python wxpython

我正在尝试使用以下代码预先填充 wxPython DatePicker 的值:

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

以下是打印值:

  • 运行数据 [2] = 12/16/09 00:00
  • 月、日、年 = 12 16 09
  • 显示日期 = 12/16/09 00:00:00

但是,datePicker 总是显示今天的日期。

有任何想法吗?

我在 Windows 7 上使用 Python 2.6.4 和 wxPython 2.8.10.1。

谢谢。


20/12/09 16:30 更新:

当我尝试处理来自有问题的 DatePickerCtrl 的信息时,出现以下错误:

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
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

Fog*_*ird 2

您是否尝试过将年份设为 2009 而不是 9?