Source code for enaml.wx.wx_date_selector
#------------------------------------------------------------------------------
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
import wx
from .wx_bounded_date import WxBoundedDate
[docs]class WxDateSelector(WxBoundedDate):
""" A Wx implementation of an Enaml DateSelector.
"""
#--------------------------------------------------------------------------
# Setup methods
#--------------------------------------------------------------------------
[docs] def create(self, tree):
""" Create and initialize the date selector control.
"""
super(WxDateSelector, self).create(tree)
self.set_date_format(tree['date_format'])
self.widget().Bind(wx.EVT_DATE_CHANGED, self.on_date_changed)
#--------------------------------------------------------------------------
# Message Handling
#--------------------------------------------------------------------------
[docs] def get_date(self):
""" Return the current date in the control.
Returns
-------
result : wxDateTime
The current control date as a wxDateTime object.
"""
return self.widget().GetValue()
[docs] def set_date(self, date):
""" Set the widget's current date.
Parameters
----------
date : wxDateTime
The wxDateTime object to use for setting the date.
"""
self.widget().SetValue(date)
[docs] def set_max_date(self, date):
""" Set the widget's maximum date.
Parameters
----------
date : wxDateTime
The wxDateTime object to use for setting the maximum date.
"""
widget = self.widget()
widget.SetRange(widget.GetLowerLimit(), date)
[docs] def set_min_date(self, date):
""" Set the widget's minimum date.
Parameters
----------
date : wxDateTime
The wxDateTime object to use for setting the minimum date.
"""
widget = self.widget()
widget.SetRange(date, widget.GetUpperLimit())