如何重置wxDatePickerCtrl的ALLOWNONE状态?

时间:2016-07-06 21:40:11

标签: python sqlite sqlalchemy wxpython wxformbuilder

下面的代码使用sqlalchemy检查sqlite3映射表(Ppe)的日期。 然后,它使用这些日期在comboBox事件上填充wxForm上的字段。

def refresh_ppe( self, event ):
        selected_user = str(self.m_comboBox31.GetValue())
        session = start_session()
        updater = session.query(Ppe).filter(Ppe.name == selected_user).first()
        new_date = updater.ear_defenders
        try:
            self.m_datePicker23.SetValue(_pydate2wxdate(new_date))
        except AssertionError:
            self.m_datePicker23.SetValue(None)

Image of control in question.

我正在尝试做的是当我使用带有防御者的Null日期的条目重新填充表时(因为它们尚未发布它们)它重置了DatePickerCtrl的ALLOWNONE状态并清除了复选框。

我尝试过self.m_panel1681.Refresh()(父面板),并尝试隐藏并显示面板和DatePickerCtrl。

任何帮助都会得到很好的回复。

由于 保罗。

1 个答案:

答案 0 :(得分:0)

The wxDP_ALLOWNONE is a flag so it shouldn't be losing that unless it is explicitly removed. I assume that what you mean is the visual state of the widget and what is done for that is up to the native control and how it chooses to represent the current value. The usual pattern for things like this in wxWidgets is to use an invalid object of the given type to represent empty, null, default, etc. So I would try using self.m_datePicker23.SetValue(wx.DefaultDateTime).