Skip to content

Calendar

flaui.core.automation_elements.Calendar

Bases: AutomationElement

Class to interact with a calendar element. Not supported for Windows Forms calendar

selected_dates property

Gets the selected dates in the calendar. For Win32 multiple selection calendar the returned array has two dates, the first date and the last date of the selected range. For WPF calendar the returned array contains all selected dates

Returns:

Type Description
List[date]

Selected dates

add_range_to_selection(dates)

For WPF calendar with SelectionMode="MultipleRange" this method adds the specified range to current selection. For any other type of SelectionMode it deselects other selected dates and selects only the last date in the range. This method is supported only for WPF calendar.

Parameters:

Name Type Description Default
dates List[date]

Date ranges

required
Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def add_range_to_selection(self, dates: List[date]) -> None:
    """For WPF calendar with SelectionMode="MultipleRange" this method adds the specified range to current selection.
    For any other type of SelectionMode it deselects other selected dates and selects only the last date in the range.
    This method is supported only for WPF calendar.

    :param dates: Date ranges
    """
    self.raw_element.AddRangeToSelection([TypeCast.cs_datetime(_) for _ in dates])

add_to_selection(date)

For WPF calendar with SelectionMode="MultipleRange" this method adds the specified date to current selection. For any other type of SelectionMode it deselects other selected dates and selects the specified date. This method is supported only for WPF calendar.

Parameters:

Name Type Description Default
date date

Date object

required
Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def add_to_selection(self, date: date) -> None:
    """For WPF calendar with SelectionMode="MultipleRange" this method adds the specified date to current selection.
    For any other type of SelectionMode it deselects other selected dates and selects the specified date.
    This method is supported only for WPF calendar.

    :param date: Date object
    """
    self.raw_element.AddToSelection(TypeCast.cs_datetime(date))

select_date(date)

Deselects other selected dates and selects the specified date.

Parameters:

Name Type Description Default
date date

Date object

required
Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def select_date(self, date: date) -> None:
    """Deselects other selected dates and selects the specified date.

    :param date: Date object
    """
    self.raw_element.SelectDate(TypeCast.cs_datetime(date))

select_range(dates)

For WPF calendar with SelectionMode="MultipleRange" this method deselects other selected dates and selects the specified range. For any other type of SelectionMode it deselects other selected dates and selects only the last date in the range. For Win32 multiple selection calendar the "dates" parameter should contain two dates, the first and the last date of the range to be selected. For Win32 single selection calendar this method selects only the second date from the "dates" array. For WPF calendar all dates should be specified in the "dates" parameter, not only the first and the last date of the range.

Parameters:

Name Type Description Default
dates List[date]

Date ranges

required
Source code in flaui/core/automation_elements.py
@handle_csharp_exceptions
def select_range(self, dates: List[date]) -> None:
    """For WPF calendar with SelectionMode="MultipleRange" this method deselects other selected dates and selects the specified range.
    For any other type of SelectionMode it deselects other selected dates and selects only the last date in the range.
    For Win32 multiple selection calendar the "dates" parameter should contain two dates, the first and the last date of the range to be selected.
    For Win32 single selection calendar this method selects only the second date from the "dates" array.
    For WPF calendar all dates should be specified in the "dates" parameter, not only the first and the last date of the range.

    :param dates: Date ranges
    """
    self.raw_element.SelectRange([TypeCast.cs_datetime(_) for _ in dates])