Calendar

../_images/calendar-preview.png

Widget description

This is a calendar widget.

It helps applications to flexibly display a calender with day of the week, date, year and month. Applications are able to set specific dates to be reported back, when selected, in the smart callbacks of the calendar widget. The API of this widget lets the applications perform other functions, like:

  • placing marks on specific dates

  • setting the bounds for the calendar (minimum and maximum years)

  • setting the day names of the week (e.g. “Thu” or “Thursday”)

  • setting the year and month format.

Emitted signals

  • changed - emitted when the date in the calendar is changed.

  • display,changed - emitted when the current month displayed in the calendar is changed.

Enumerations

Calendar mark repeat types

efl.elementary.ELM_CALENDAR_UNIQUE

Default value.

Marks will be displayed only on event day.

efl.elementary.ELM_CALENDAR_DAILY

Marks will be displayed every day after event day (inclusive).

efl.elementary.ELM_CALENDAR_WEEKLY

Marks will be displayed every week after event day (inclusive) - i.e. each seven days.

efl.elementary.ELM_CALENDAR_MONTHLY

Marks will be displayed every month day that coincides to event day.

E.g.: if an event is set to 30th Jan, no marks will be displayed on Feb, but will be displayed on 30th Mar

efl.elementary.ELM_CALENDAR_ANNUALLY

Marks will be displayed every year that coincides to event day (and month).

E.g. an event added to 30th Jan 2012 will be repeated on 30th Jan 2013.

efl.elementary.ELM_CALENDAR_LAST_DAY_OF_MONTH

Marks will be displayed every last day of month after event day (inclusive).

efl.elementary.ELM_CALENDAR_REVERSE_DAILY

Marks will be displayed every day before event day.

New in version 1.19.

Calendar selection modes

efl.elementary.ELM_CALENDAR_SELECT_MODE_DEFAULT

Default mode

efl.elementary.ELM_CALENDAR_SELECT_MODE_ALWAYS

Select always

efl.elementary.ELM_CALENDAR_SELECT_MODE_NONE

Don’t select

efl.elementary.ELM_CALENDAR_SELECT_MODE_ONDEMAND

Select on demand

Selectable

efl.elementary.ELM_CALENDAR_SELECTABLE_NONE

None selectable

efl.elementary.ELM_CALENDAR_SELECTABLE_YEAR

Year is selectable

efl.elementary.ELM_CALENDAR_SELECTABLE_MONTH

Month is selectable

efl.elementary.ELM_CALENDAR_SELECTABLE_DAY

Day is selectable

Days

efl.elementary.ELM_DAY_SUNDAY

Sunday

efl.elementary.ELM_DAY_MONDAY

Monday

efl.elementary.ELM_DAY_TUESDAY

Tuesday

efl.elementary.ELM_DAY_WEDNESDAY

Wednesday

efl.elementary.ELM_DAY_THURSDAY

Thursday

efl.elementary.ELM_DAY_FRIDAY

Friday

efl.elementary.ELM_DAY_SATURDAY

Saturday

Inheritance diagram

Inheritance diagram of Calendar, CalendarMark
class efl.elementary.Calendar(Object parent, *args, **kwargs)

Bases: efl.elementary.__init__.LayoutClass

This is the class that actually implements the widget.

Parameters
  • parent (efl.evas.Object) – The parent object

  • **kwargs – All the remaining keyword arguments are interpreted as properties of the instance

callback_changed_add(func, *args, **kwargs)

Emitted when the date in the calendar is changed.

callback_changed_del(func)
callback_display_changed_add(func, *args, **kwargs)

Emitted when the current month displayed in the calendar is changed.

date_max

Maximum date on calendar.

Type

datetime.date

New in version 1.19.

date_max_get()
date_max_set(max_date)
date_min

Minimum date on calendar.

Type

datetime.date

New in version 1.19.

date_min_get()
date_min_set(min_date)
displayed_time

Get the current time displayed in the widget

Type

datetime.date

New in version 1.8.

first_day_of_week

The first day of week to use on the calendar widget.

Type

int

interval

Set the interval on time updates for an user mouse button hold on calendar widgets’ month selection.

This interval value is decreased while the user holds the mouse pointer either selecting next or previous month.

This helps the user to get to a given month distant from the current one easier/faster, as it will start to change quicker and quicker on mouse button holds.

The calculation for the next change interval value, starting from the one set with this call, is the previous interval divided by 1.05, so it decreases a little bit.

The default starting interval value for automatic changes is 0.85 seconds.

Type

float

mark_add(mark_type, mark_time, repeat)

A constructor for a CalendarMark.

Parameters
  • mark_type (string) – A string used to define the type of mark. It will be emitted to the theme, that should display a related modification on these days representation.

  • mark_time (datetime.date) – A date object to represent the date of inclusion of the mark. For marks that repeats it will just be displayed after the inclusion date in the calendar.

  • repeat (Calendar mark repeat types) – Repeat the event following this periodicity. Can be a unique mark (that don’t repeat), daily, weekly, monthly or annually.

Returns

The created mark or None upon failure.

Return type

CalendarMark

marks

Calendar marks.

Type

list of CalendarMark

marks_draw()

Draw calendar marks.

Should be used after adding, removing or clearing marks. It will go through the entire marks list updating the calendar. If lots of marks will be added, add all the marks and then call this function.

When the month is changed, i.e. user selects next or previous month, marks will be drawn.

Seealso

CalendarMark

min_max_year

The minimum and maximum values for the year

Maximum must be greater than minimum, except if you don’t want to set maximum year. Default values are 1902 and -1.

If the maximum year is a negative value, it will be limited depending on the platform architecture (year 2037 for 32 bits)

Type

(int min, int max)

select_mode

The day selection mode used.

Type

Calendar selection modes

selectable

How selected_time manages a date

Type

Selectable

New in version 1.8.

selected_time

Selected date on the calendar.

Setting this changes the displayed month if needed. Selected date changes when the user goes to next/previous month or select a day pressing over it on calendar.

Type

datetime.date

Changed in version 1.8: Returns None when the selected date cannot be fetched.

weekdays_names

The weekdays’ names to be displayed by the calendar.

By default, weekdays abbreviations get from system are displayed: E.g. for an en_US locale: “Sun, Mon, Tue, Wed, Thu, Fri, Sat”

The first string should be related to Sunday, the second to Monday…

The usage should be like this:

weekdays =
(
  "Sunday", "Monday", "Tuesday", "Wednesday",
  "Thursday", "Friday", "Saturday"
)
calendar.weekdays_names = weekdays
Type

tuple of strings

Warning

It must have 7 elements, or it will access invalid memory.

class efl.elementary.CalendarMark(Object cal, mark_type, mark_time, Elm_Calendar_Mark_Repeat_Type repeat)

Bases: object

An item for the Calendar widget.

A mark that will be drawn in the calendar respecting the insertion time and periodicity. It will emit the type as signal to the widget theme. Default theme supports “holiday” and “checked”, but it can be extended.

Instantiating it won’t immediately update the calendar, drawing the marks. For this, call Calendar.marks_draw(). However, when user selects next or previous month calendar forces marks drawn.

Marks created with this method can be deleted with delete().

Example:

from datetime import date, timedelta

cal = Calendar(win)

selected_time = date.today() + timedelta(5)
cal.mark_add("holiday", selected_time, ELM_CALENDAR_ANNUALLY)

selected_time = date.today() + timedelta(1)
cal.mark_add("checked", selected_time, ELM_CALENDAR_UNIQUE)

cal.marks_draw()
Parameters
  • parent (efl.evas.Object) – The parent object

  • mark_type (string) – A string used to define the type of mark. It will be emitted to the theme, that should display a related modification on these days representation.

  • mark_time (datetime.date) – A date object to represent the date of inclusion of the mark. For marks that repeats it will just be displayed after the inclusion date in the calendar.

  • repeat (Calendar mark repeat types) – Repeat the event following this periodicity. Can be a unique mark (that don’t repeat), daily, weekly, monthly or annually.

Returns

The created mark or None upon failure.

Return type

CalendarMark

delete()

Delete a mark from the calendar.

If deleting all calendar marks is required, del Calendar.marks should be used instead of getting marks list and deleting each one.

Parameters

mark (CalendarMark) – The mark to be deleted.