Source code for enamlnative.widgets.date_picker

"""
Copyright (c) 2017-2022, CodeLV.

Distributed under the terms of the MIT License.

The full license is in the file LICENSE, distributed with this software.

Created on May 20, 2017

 
"""
from datetime import datetime
from atom.api import ForwardTyped, Instance, Range, Typed
from enaml.core.declarative import d_, observe
from .frame_layout import FrameLayout, ProxyFrameLayout


class ProxyDatePicker(ProxyFrameLayout):
    """The abstract definition of a proxy Label object."""

    #: A reference to the Label declaration.
    declaration = ForwardTyped(lambda: DatePicker)

    def set_first_day_of_week(self, day):
        raise NotImplementedError

    def set_date(self, date):
        raise NotImplementedError

    def set_min_date(self, date):
        raise NotImplementedError

    def set_max_date(self, date):
        raise NotImplementedError


[docs]class DatePicker(FrameLayout): """A simple control for displaying read-only text.""" #: Update the current year. date = d_(Instance(datetime, factory=datetime.now)) #: Sets the minimal date supported by this DatePicker in milliseconds #: since January 1, 1970 00:00:00 in getDefault() time zone. min_date = d_(Instance(datetime, factory=datetime.now)) #: Sets the maximal date supported by this DatePicker in milliseconds #: since January 1, 1970 00:00:00 in getDefault() time zone. max_date = d_(Instance(datetime, factory=datetime.now)) #: Sets the first day of week. first_day_of_week = d_(Range(1, 7)) #: A reference to the ProxyLabel object. proxy = Typed(ProxyDatePicker) # ------------------------------------------------------------------------- # Observers # ------------------------------------------------------------------------- @observe("date", "min_date", "max_date", "first_day_of_week") def _update_proxy(self, change): super()._update_proxy(change)