2021-10-25 18:51:39 +02:00
|
|
|
|
2023-02-20 20:50:58 +01:00
|
|
|
def event_handler(e):
|
|
|
|
code = e.get_code()
|
2021-06-07 13:56:08 +02:00
|
|
|
|
|
|
|
if code == lv.EVENT.VALUE_CHANGED:
|
2023-03-23 03:35:07 +01:00
|
|
|
source = e.get_current_target_obj()
|
2021-06-07 13:56:08 +02:00
|
|
|
date = lv.calendar_date_t()
|
2023-09-18 22:57:30 +02:00
|
|
|
if source.get_pressed_date(date) == lv.RESULT.OK:
|
2021-07-11 18:39:08 +03:00
|
|
|
calendar.set_today_date(date.year, date.month, date.day)
|
|
|
|
print("Clicked date: %02d.%02d.%02d"%(date.day, date.month, date.year))
|
2022-03-21 18:25:51 +08:00
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
|
2023-10-12 20:37:27 +02:00
|
|
|
calendar = lv.calendar(lv.screen_active())
|
2021-06-07 13:56:08 +02:00
|
|
|
calendar.set_size(200, 200)
|
|
|
|
calendar.align(lv.ALIGN.CENTER, 0, 20)
|
2023-02-20 20:50:58 +01:00
|
|
|
calendar.add_event(event_handler, lv.EVENT.ALL, None)
|
2021-06-07 13:56:08 +02:00
|
|
|
|
|
|
|
calendar.set_today_date(2021, 02, 23)
|
|
|
|
calendar.set_showed_date(2021, 02)
|
|
|
|
|
|
|
|
# Highlight a few days
|
2021-07-11 18:39:08 +03:00
|
|
|
highlighted_days=[
|
|
|
|
lv.calendar_date_t({'year':2021, 'month':2, 'day':6}),
|
|
|
|
lv.calendar_date_t({'year':2021, 'month':2, 'day':11}),
|
|
|
|
lv.calendar_date_t({'year':2021, 'month':2, 'day':22})
|
|
|
|
]
|
|
|
|
|
|
|
|
calendar.set_highlighted_dates(highlighted_days, len(highlighted_days))
|
|
|
|
|
2021-10-25 18:51:39 +02:00
|
|
|
lv.calendar_header_dropdown(calendar)
|