后板第一次提交
This commit is contained in:
7
lvgl_v8_back/lvgl/examples/widgets/calendar/index.rst
Executable file
7
lvgl_v8_back/lvgl/examples/widgets/calendar/index.rst
Executable file
@@ -0,0 +1,7 @@
|
||||
|
||||
Calendar with header
|
||||
""""""""""""""""""""""
|
||||
|
||||
.. lv_example:: widgets/calendar/lv_example_calendar_1
|
||||
:language: c
|
||||
|
||||
51
lvgl_v8_back/lvgl/examples/widgets/calendar/lv_example_calendar_1.c
Executable file
51
lvgl_v8_back/lvgl/examples/widgets/calendar/lv_example_calendar_1.c
Executable file
@@ -0,0 +1,51 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CALENDAR && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_current_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_calendar_date_t date;
|
||||
if(lv_calendar_get_pressed_date(obj, &date)) {
|
||||
LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_example_calendar_1(void)
|
||||
{
|
||||
lv_obj_t * calendar = lv_calendar_create(lv_scr_act());
|
||||
lv_obj_set_size(calendar, 185, 185);
|
||||
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 27);
|
||||
lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
lv_calendar_set_today_date(calendar, 2021, 02, 23);
|
||||
lv_calendar_set_showed_date(calendar, 2021, 02);
|
||||
|
||||
/*Highlight a few days*/
|
||||
static lv_calendar_date_t highlighted_days[3]; /*Only its pointer will be saved so should be static*/
|
||||
highlighted_days[0].year = 2021;
|
||||
highlighted_days[0].month = 02;
|
||||
highlighted_days[0].day = 6;
|
||||
|
||||
highlighted_days[1].year = 2021;
|
||||
highlighted_days[1].month = 02;
|
||||
highlighted_days[1].day = 11;
|
||||
|
||||
highlighted_days[2].year = 2022;
|
||||
highlighted_days[2].month = 02;
|
||||
highlighted_days[2].day = 22;
|
||||
|
||||
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
|
||||
|
||||
#if LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
lv_calendar_header_dropdown_create(calendar);
|
||||
#elif LV_USE_CALENDAR_HEADER_ARROW
|
||||
lv_calendar_header_arrow_create(calendar);
|
||||
#endif
|
||||
lv_calendar_set_showed_date(calendar, 2021, 10);
|
||||
}
|
||||
|
||||
#endif
|
||||
30
lvgl_v8_back/lvgl/examples/widgets/calendar/lv_example_calendar_1.py
Executable file
30
lvgl_v8_back/lvgl/examples/widgets/calendar/lv_example_calendar_1.py
Executable file
@@ -0,0 +1,30 @@
|
||||
|
||||
def event_handler(evt):
|
||||
code = evt.get_code()
|
||||
|
||||
if code == lv.EVENT.VALUE_CHANGED:
|
||||
source = evt.get_current_target()
|
||||
date = lv.calendar_date_t()
|
||||
if source.get_pressed_date(date) == lv.RES.OK:
|
||||
calendar.set_today_date(date.year, date.month, date.day)
|
||||
print("Clicked date: %02d.%02d.%02d"%(date.day, date.month, date.year))
|
||||
|
||||
|
||||
calendar = lv.calendar(lv.scr_act())
|
||||
calendar.set_size(200, 200)
|
||||
calendar.align(lv.ALIGN.CENTER, 0, 20)
|
||||
calendar.add_event_cb(event_handler, lv.EVENT.ALL, None)
|
||||
|
||||
calendar.set_today_date(2021, 02, 23)
|
||||
calendar.set_showed_date(2021, 02)
|
||||
|
||||
# Highlight a few days
|
||||
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))
|
||||
|
||||
lv.calendar_header_dropdown(calendar)
|
||||
Reference in New Issue
Block a user