Skip to content

Commit b818b56

Browse files
gregornitheCapypara
authored andcommitted
Library: Port 'Calendar' to Python
1 parent 2498e08 commit b818b56

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Library/demos/Calendar/main.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import workbench
2+
3+
calendar = workbench.builder.get_object("calendar")
4+
5+
# calendar.get_date() returns a GLib.DateTime object
6+
# https://docs.gtk.org/glib/struct.DateTime.html
7+
8+
calendar.connect("notify::day",
9+
lambda *_: print(calendar.get_date().format("%e"))
10+
)
11+
12+
calendar.connect("notify::month",
13+
lambda *_:print(calendar.get_date().format("%B"))
14+
)
15+
16+
calendar.connect("notify::year",
17+
lambda *_: print(calendar.get_date().format("%Y"))
18+
)
19+
20+
calendar.connect("day-selected",
21+
lambda *_: print(calendar.get_date().format_iso8601())
22+
)
23+
24+
calendar.mark_day(15)

0 commit comments

Comments
 (0)