Skip to content

Date Picker

morphui.uix.pickers.datepicker

BaseDatePickerListView(**kwargs)

Bases: BaseListView

Base class for date picker list views.

This class serves as a foundation for specific date picker views such as year and month views.

set_active_by_text(text)

Set the active item based on the label text.

This method iterates through the list items and sets the active state of the item whose label text matches the provided text.

PARAMETER DESCRIPTION
text

The label text of the item to set as active.

TYPE: str

MorphDatePickerYearView(**kwargs)

Bases: BaseDatePickerListView

A year view for the date picker component.

This view displays a grid of years for selection within the date picker.

year_start = NumericProperty(1970) class-attribute instance-attribute

The starting year for the year view.

This property defines the first year displayed in the year view.

:attr:year_start is a :class:kivy.properties.NumericProperty and defaults to 1970.

year_end = NumericProperty(2100) class-attribute instance-attribute

The ending year for the year view.

This property defines the last year displayed in the year view.

:attr:year_end is a :class:kivy.properties.NumericProperty and defaults to 2100.

current_year = NumericProperty(date.today().year) class-attribute instance-attribute

The currently selected year.

:attr:current_year is a :class:kivy.properties.NumericProperty and defaults to 2024.

default_scroll_y = self.default_scroll_y class-attribute instance-attribute

The default scroll position for the year view (read-only).

This property is automatically calculated based on the :attr:year_start, :attr:year_end, and :attr:current_year properties to ensure that the current year is visible when the view is first displayed.

:attr:default_scroll_y is a :class:kivy.properties.AliasProperty that is read-only and bound to the relevant year properties.

MorphDatePickerMonthView(**kwargs)

Bases: BaseDatePickerListView

A month view for the date picker component.

This view displays a grid of months for selection within the date picker.

current_month = NumericProperty(date.today().month) class-attribute instance-attribute

The currently selected month.

This property defines the month that is currently selected in the month view.

:attr:current_month is a :class:kivy.properties.NumericProperty and defaults to current month.

month_names = ListProperty([(month_name[i]) for i in (range(1, 13))]) class-attribute instance-attribute

List of month names to display in the month view.

:attr:month_names is a :class:kivy.properties.ListProperty and defaults to the full names of the months from January to December.

current_month_name = AliasProperty(lambda self: self.month_names[self.current_month - 1], bind=['current_month', 'month_names']) class-attribute instance-attribute

The name of the currently selected month (read-only).

:attr:current_month_name is a :class:kivy.properties.AliasProperty that derives its value from :attr:current_month and :attr:month_names.

MorphDatePickerCalendarView(**kwargs)

Bases: MorphBoxLayout

A calendar view for the date picker component.

This view displays a calendar grid for a specific month and year, allowing date selection.

kind = StringProperty('single') class-attribute instance-attribute

The selection mode of the calendar view.

This property defines whether the calendar allows single date selection or range selection.

:attr:kind is a :class:kivy.properties.StringProperty and defaults to 'single'.

selected_dates = ListProperty([]) class-attribute instance-attribute

List of currently selected dates.

This property holds the list of :class:datetime.date values that are currently selected in the calendar view.

:attr:selected_dates is a :class:kivy.properties.ListProperty and defaults to an empty list.

weekday_headers = ListProperty(list(day_abbr)) class-attribute instance-attribute

List of weekday abbreviations to display as headers.

:attr:weekday_headers is a :class:kivy.properties.ListProperty and defaults to the abbreviated names of the weekdays from Monday to Sunday.

date_values = ListProperty([]) class-attribute instance-attribute

List of date values to display in the calendar grid.

:attr:date_values is a :class:kivy.properties.ListProperty and defaults to an empty list.

clear_selection()

Clear the current date selection in the calendar view.

This method resets the selection state, removing any selected dates.

MorphDockedDatePickerMenu(**kwargs)

Bases: MorphSizeBoundsBehavior, MorphMenuMotionBehavior, MorphElevationBoxLayout

calendar = Calendar(firstweekday=0) class-attribute instance-attribute

The calendar instance used for date calculations.

:attr:calendar is a standard Python :class:calendar.Calendar instance initialized with the first weekday set to Monday.

current_year = NumericProperty(date.today().year) class-attribute instance-attribute

The currently selected year.

:attr:current_year is a :class:kivy.properties.NumericProperty and defaults to 2024.

current_month = NumericProperty(date.today().month) class-attribute instance-attribute

The currently selected month.

This property defines the month that is currently selected in the month view.

:attr:current_month is a :class:kivy.properties.NumericProperty and defaults to current month.

kind = StringProperty('single') class-attribute instance-attribute

The selection mode of the date picker menu.

This property defines whether the date picker allows single date selection or range selection.

:attr:kind is a :class:kivy.properties.StringProperty and defaults to 'single'.

change_view(button, screen_name)

Navigate to the month selection view.

MorphDockedDatePickerField(**kwargs)

Bases: MorphTextField

A date picker text field designed to be used with a docked layout such as MorphDockedDatePicker.

This text field integrates with a docked date picker layout to provide date selection functionality.

Examples:

Single date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerField
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerField(
                kind='single',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()

Range date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerField
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerField(
                kind='range',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()

normal_trailing_icon = StringProperty('calendar') class-attribute instance-attribute

Icon for the normal (closed) state of the dropdown filter field.

This property holds the icon name used when the dropdown is in its normal (closed) state. Other possible values could be 'menu-down', 'chevron-down', etc.

:attr:normal_trailing_icon is a :class:~kivy.properties.StringProperty and defaults to 'chevron-down'.

focus_trailing_icon = StringProperty('') class-attribute instance-attribute

Icon for the focused (open) state of the dropdown filter field.

This property holds the icon name used when the dropdown is in its focused (open) state. Other possible values could be 'menu-up', 'chevron-up', etc.

:attr:focus_trailing_icon is a :class:~kivy.properties.StringProperty and defaults to ''.

picker_menu = ObjectProperty(None) class-attribute instance-attribute

Reference to the associated date picker menu.

This property holds a reference to the :class:~morphui.uix.pickers.MorphDockedDatePickerMenu instance that is associated with this text field. It allows the text field to interact with the date picker menu for date selection.

:attr:picker_menu is a :class:~kivy.properties.ObjectProperty and is instantiated during the initialization of the text field.

kind = StringProperty('single') class-attribute instance-attribute

The selection mode of the date picker menu.

This property defines whether the date picker allows single date selection or range selection.

:attr:kind is a :class:kivy.properties.StringProperty and defaults to 'single'.

date_format = OptionProperty('eu', options=['iso', 'us', 'eu']) class-attribute instance-attribute

The date format used for displaying selected dates.

This property defines the format in which selected dates are displayed in the text field. Possible values include 'iso' (YYYY-MM-DD), 'us' (MM/DD/YYYY), and 'eu' (DD.MM.YYYY).

:attr:date_format is a :class:kivy.properties.OptionProperty and defaults to 'eu'.

range_sep = StringProperty(' - ') class-attribute instance-attribute

Separator used between start and end dates in range selection.

This property defines the string used to separate the start and end dates when the date picker is in range selection mode.

:attr:range_sep is a :class:kivy.properties.StringProperty and defaults to ' - '.

calendar_view property

Get the calendar view from the associated date picker menu.

This property provides access to the :class:~morphui.uix.pickers.MorphDatePickerCalendarView instance within the associated date picker menu.

:return: The calendar view instance. :rtype: MorphDatePickerCalendarView

format_string property

Get the strftime/strptime format string based on the selected date format.

This property retrieves the appropriate format string for date parsing and formatting based on the current value of the :attr:date_format property.

:return: The corresponding format string. :rtype: str

MorphDockedDatePickerFieldOutlined(**kwargs)

Bases: MorphDockedDatePickerField

An outlined variant of the MorphDockedDatePickerField.

This class extends the MorphDockedDatePickerField to provide an outlined style for the date picker text field.

Examples:

Single date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerFieldOutlined
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerFieldOutlined(
                kind='single',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()

range date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerFieldOutlined
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerFieldOutlined(
                kind='range',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout
if __name__ == "__main__":
    MyApp().run()

MorphDockedDatePickerFieldRounded(**kwargs)

Bases: MorphRoundSidesBehavior, MorphDockedDatePickerField

A rounded variant of the MorphDockedDatePickerField.

This class extends the MorphDockedDatePickerField to provide a rounded style for the date picker text field.

Examples:

Single date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerFieldRounded
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerFieldRounded(
                kind='single',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()

Range date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerFieldRounded
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerFieldRounded(
                kind='range',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()

MorphDockedDatePickerFieldFilled(**kwargs)

Bases: MorphDockedDatePickerField

A filled variant of the MorphDockedDatePickerField.

This class extends the MorphDockedDatePickerField to provide a filled style for the date picker text field.

Examples:

Single date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerFieldFilled
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerFieldFilled(
                kind='single',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.6,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()

Range date selection:

from morphui.app import MorphApp
from morphui.uix.pickers import MorphDockedDatePickerFieldFilled
from morphui.uix.floatlayout import MorphFloatLayout

class MyApp(MorphApp):

    def build(self) -> MorphFloatLayout:
        self.theme_manager.theme_mode = 'Dark'
        self.theme_manager.seed_color = 'morphui_teal'

        self.layout = MorphFloatLayout(
            MorphDockedDatePickerFieldFilled(
                kind='range',
                identity='date_picker_field',
                pos_hint={'center_x': 0.5, 'center_y': 0.8},
                size_hint_x= 0.,))

        return self.layout

if __name__ == "__main__":
    MyApp().run()