Gtk.Calendar

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.Calendar Gtk.Calendar Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Gtk.Calendar

Example

../_images/Calendar.png
Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

clear_marks ()

get_date ()

get_day_is_marked (day)

get_show_day_names ()

get_show_heading ()

get_show_week_numbers ()

mark_day (day)

select_day (date)

set_show_day_names (value)

set_show_heading (value)

set_show_week_numbers (value)

unmark_day (day)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1)

Name

Type

Flags

Short Description

day

int

r/w/en

month

int

r/w/en

show-day-names

bool

r/w/en

show-heading

bool

r/w/en

show-week-numbers

bool

r/w/en

year

int

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

day-selected

Emitted when the user selects a day.

next-month

Emitted when the user switched to the next month.

next-year

Emitted when user switched to the next year.

prev-month

Emitted when the user switched to the previous month.

prev-year

Emitted when user switched to the previous year.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Gtk.Calendar(**kwargs)
Bases:

Gtk.Widget

Abstract:

No

GtkCalendar is a widget that displays a Gregorian calendar, one month at a time.

An example Gtk.Calendar

A GtkCalendar can be created with [ctor`Gtk`.Calendar.new].

The date that is currently displayed can be altered with [method`Gtk`.Calendar.select_day].

To place a visual marker on a particular day, use [method`Gtk`.Calendar.mark_day] and to remove the marker, [method`Gtk`.Calendar.unmark_day]. Alternative, all marks can be cleared with [method`Gtk`.Calendar.clear_marks].

The selected date can be retrieved from a GtkCalendar using [method`Gtk`.Calendar.get_date].

Users should be aware that, although the Gregorian calendar is the legal calendar in most countries, it was adopted progressively between 1582 and 1929. Display before these dates is likely to be historically incorrect.

CSS nodes

`` calendar.view ├── header │ ├── button │ ├── stack.month │ ├── button │ ├── button │ ├── label.year │ ╰── button ╰── grid

╰── label[.day-name][.week-number][.day-number][.other-month][.today]

``

GtkCalendar has a main node with name calendar. It contains a subnode called header containing the widgets for switching between years and months.

The grid subnode contains all day labels, including week numbers on the left (marked with the .week-number css class) and day names on top (marked with the .day-name css class).

Day labels that belong to the previous or next month get the .other-month style class. The label of the current day get the .today style class.

Marked day labels get the :selected state assigned.

classmethod new()[source]
Returns:

a newly GtkCalendar widget

Return type:

Gtk.Widget

Creates a new calendar, with the current date being selected.

clear_marks()[source]

Remove all visual markers.

get_date()[source]
Returns:

the GDate representing the shown date

Return type:

GLib.DateTime

Returns a GDateTime representing the shown year, month and the selected day.

The returned date is in the local time zone.

get_day_is_marked(day)[source]
Parameters:

day (int) – the day number between 1 and 31.

Returns:

whether the day is marked.

Return type:

bool

Returns if the day of the self is already marked.

get_show_day_names()[source]
Returns:

Whether the calendar shows day names.

Return type:

bool

Returns whether self is currently showing the names of the week days.

This is the value of the [property`Gtk`.Calendar:show-day-names] property.

get_show_heading()[source]
Returns:

Whether the calendar is showing a heading.

Return type:

bool

Returns whether self is currently showing the heading.

This is the value of the [property`Gtk`.Calendar:show-heading] property.

get_show_week_numbers()[source]
Returns:

Whether the calendar is showing week numbers.

Return type:

bool

Returns whether self is showing week numbers right now.

This is the value of the [property`Gtk`.Calendar:show-week-numbers] property.

mark_day(day)[source]
Parameters:

day (int) – the day number to mark between 1 and 31.

Places a visual marker on a particular day of the current month.

select_day(date)[source]
Parameters:

date (GLib.DateTime) – a GDateTime representing the day to select

Switches to date's year and month and select its day.

set_show_day_names(value)[source]
Parameters:

value (bool) – Whether to show day names above the day numbers

Sets whether the calendar shows day names.

set_show_heading(value)[source]
Parameters:

value (bool) – Whether to show the heading in the calendar

Sets whether the calendar should show a heading.

The heading contains the current year and month as well as buttons for changing both.

set_show_week_numbers(value)[source]
Parameters:

value (bool) – whether to show week numbers on the left of the days

Sets whether week numbers are shown in the calendar.

unmark_day(day)[source]
Parameters:

day (int) – the day number to unmark between 1 and 31.

Removes the visual marker from a particular day.

Signal Details

Gtk.Calendar.signals.day_selected(calendar)
Signal Name:

day-selected

Flags:

RUN_FIRST

Parameters:

calendar (Gtk.Calendar) – The object which received the signal

Emitted when the user selects a day.

Gtk.Calendar.signals.next_month(calendar)
Signal Name:

next-month

Flags:

RUN_FIRST

Parameters:

calendar (Gtk.Calendar) – The object which received the signal

Emitted when the user switched to the next month.

Gtk.Calendar.signals.next_year(calendar)
Signal Name:

next-year

Flags:

RUN_FIRST

Parameters:

calendar (Gtk.Calendar) – The object which received the signal

Emitted when user switched to the next year.

Gtk.Calendar.signals.prev_month(calendar)
Signal Name:

prev-month

Flags:

RUN_FIRST

Parameters:

calendar (Gtk.Calendar) – The object which received the signal

Emitted when the user switched to the previous month.

Gtk.Calendar.signals.prev_year(calendar)
Signal Name:

prev-year

Flags:

RUN_FIRST

Parameters:

calendar (Gtk.Calendar) – The object which received the signal

Emitted when user switched to the previous year.

Property Details

Gtk.Calendar.props.day
Name:

day

Type:

int

Default Value:

1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The selected day (as a number between 1 and 31).

Gtk.Calendar.props.month
Name:

month

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The selected month (as a number between 0 and 11).

This property gets initially set to the current month.

Gtk.Calendar.props.show_day_names
Name:

show-day-names

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Determines whether day names are displayed.

Gtk.Calendar.props.show_heading
Name:

show-heading

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Determines whether a heading is displayed.

Gtk.Calendar.props.show_week_numbers
Name:

show-week-numbers

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Determines whether week numbers are displayed.

Gtk.Calendar.props.year
Name:

year

Type:

int

Default Value:

1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The selected year.

This property gets initially set to the current year.