tragle event ref issue on CI

This commit is contained in:
Lyon 2024-01-04 21:31:35 +08:00
parent 8055b9de00
commit 5ab99b06ce
4 changed files with 143 additions and 21 deletions

View File

@ -803,13 +803,47 @@ class dropdown(lv_obj):
def close(self): ...
def is_open(self) -> int: ...
"""
lv_obj_t * lv_label_create(lv_obj_t * parent);
void lv_label_set_text(lv_obj_t * obj, const char * text);
void lv_label_set_text_fmt(lv_obj_t * obj, const char * fmt, ...) LV_FORMAT_ATTRIBUTE(2, 3);
void lv_label_set_text_static(lv_obj_t * obj, const char * text);
void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode);
void lv_label_set_recolor(lv_obj_t * obj, bool en);
void lv_label_set_text_sel_start(lv_obj_t * obj, uint32_t index);
void lv_label_set_text_sel_end(lv_obj_t * obj, uint32_t index);
char * lv_label_get_text(const lv_obj_t * obj);
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * obj);
bool lv_label_get_recolor(const lv_obj_t * obj);
void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t * pos);
uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in);
bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos);
uint32_t lv_label_get_text_selection_start(const lv_obj_t * obj);
uint32_t lv_label_get_text_selection_end(const lv_obj_t * obj);
void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt);
void lv_label_cut_text(lv_obj_t * obj, uint32_t pos, uint32_t cnt);
"""
class label(lv_obj):
def __init__(self, parent: lv_obj): ...
def set_text(self, txt: str): ...
def set_long_mode(self, mode: int): ...
# def set_text_fmt(self, fmt: str, *args): ...
def set_text_static(self, txt: str): ...
def set_long_mode(self, long_mode: int): ...
def set_recolor(self, en: int): ...
def set_style_text_align(self, value: int, selector: int): ...
def set_text_sel_start(self, index: int): ...
def set_text_sel_end(self, index: int): ...
def get_text(self) -> str: ...
def get_long_mode(self) -> int: ...
def get_recolor(self) -> int: ...
def get_letter_pos(self, char_id: int) -> point_t: ...
def get_letter_on(self, pos_in: point_t) -> int: ...
def is_char_under_pos(self, pos: point_t) -> int: ...
def get_text_selection_start(self) -> int: ...
def get_text_selection_end(self) -> int: ...
def ins_text(self, pos: int, txt: str): ...
def cut_text(self, pos: int, cnt: int): ...
class roller(lv_obj):

View File

@ -298,32 +298,119 @@ void pika_lvgl_dropdown_set_text(PikaObj* self, char* txt) {
lv_dropdown_set_text(lv_obj, txt);
}
/*
class label(lv_obj):
def __init__(self, parent: lv_obj): ...
def set_text(self, txt: str): ...
# def set_text_fmt(self, fmt: str, *args): ...
def set_text_static(self, txt: str): ...
def set_long_mode(self, long_mode: int): ...
def set_recolor(self, en: int): ...
def set_text_sel_start(self, index: int): ...
def set_text_sel_end(self, index: int): ...
def get_text(self) -> str: ...
def get_long_mode(self) -> int: ...
def get_recolor(self) -> int: ...
def get_letter_pos(self, char_id: int) -> point_t: ...
def get_letter_on(self, pos_in: point_t) -> int: ...
def is_char_under_pos(self, pos: point_t) -> int: ...
def get_text_selection_start(self) -> int: ...
def get_text_selection_end(self) -> int: ...
def ins_text(self, pos: int, txt: str): ...
def cut_text(self, pos: int, cnt: int): ...
*/
void pika_lvgl_label___init__(PikaObj* self, PikaObj* parent) {
lv_obj_t* lv_parent = obj_getPtr(parent, "lv_obj");
lv_obj_t* lv_obj = lv_label_create(lv_parent);
obj_setPtr(self, "lv_obj", lv_obj);
}
void pika_lvgl_label_set_long_mode(PikaObj* self, int mode) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_long_mode(lv_obj, mode);
}
void pika_lvgl_label_set_recolor(PikaObj* self, int en) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_recolor(lv_obj, en);
}
void pika_lvgl_label_set_text(PikaObj* self, char* txt) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_text(lv_obj, txt);
}
void pika_lvgl_label_set_style_text_align(PikaObj* self,
int value,
int selector) {
void pika_lvgl_label_set_text_static(PikaObj* self, char* txt) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_obj_set_style_text_align(lv_obj, value, selector);
lv_label_set_text_static(lv_obj, txt);
}
void pika_lvgl_label_set_long_mode(PikaObj* self, int long_mode) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_long_mode(lv_obj, long_mode);
}
void pika_lvgl_label_set_recolor(PikaObj* self, int en) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_recolor(lv_obj, en);
}
void pika_lvgl_label_set_text_sel_start(PikaObj* self, int index) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_text_sel_start(lv_obj, index);
}
void pika_lvgl_label_set_text_sel_end(PikaObj* self, int index) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_set_text_sel_end(lv_obj, index);
}
char* pika_lvgl_label_get_text(PikaObj* self) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return (char*)lv_label_get_text(lv_obj);
}
int pika_lvgl_label_get_long_mode(PikaObj* self) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_label_get_long_mode(lv_obj);
}
int pika_lvgl_label_get_recolor(PikaObj* self) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_label_get_recolor(lv_obj);
}
PikaObj* pika_lvgl_label_get_letter_pos(PikaObj* self, int char_id) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
PikaObj* new_obj = newNormalObj(New_pika_lvgl_point_t);
lv_point_t lv_point = {0};
lv_label_get_letter_pos(lv_obj, char_id, &lv_point);
obj_setStruct(new_obj, "lv_point_struct", lv_point);
obj_setPtr(new_obj, "lv_point", obj_getStruct(new_obj, "lv_point_struct"));
return new_obj;
}
int pika_lvgl_label_get_letter_on(PikaObj* self, PikaObj* pos_in) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_point_t* lv_pos_in = obj_getPtr(pos_in, "lv_point_t");
return lv_label_get_letter_on(lv_obj, lv_pos_in);
}
int pika_lvgl_label_is_char_under_pos(PikaObj* self, PikaObj* pos) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_point_t* lv_pos = obj_getPtr(pos, "lv_point_t");
return lv_label_is_char_under_pos(lv_obj, lv_pos);
}
int pika_lvgl_label_get_text_selection_start(PikaObj* self) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_label_get_text_selection_start(lv_obj);
}
int pika_lvgl_label_get_text_selection_end(PikaObj* self) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_label_get_text_selection_end(lv_obj);
}
void pika_lvgl_label_ins_text(PikaObj* self, int pos, char* txt) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_ins_text(lv_obj, pos, txt);
}
void pika_lvgl_label_cut_text(PikaObj* self, int pos, int cnt) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_label_cut_text(lv_obj, pos, cnt);
}
void pika_lvgl_roller___init__(PikaObj* self, PikaObj* parent) {

View File

@ -3,6 +3,7 @@ import pika_lvgl as lv
import time
global_dict = {}
global_list= []
class MyMeter:
def __init__(self,
@ -221,6 +222,7 @@ class Button:
label = lv.label(btn)
label.set_text(label_text)
label.align(lv.ALIGN.CENTER, 0, 0)
# global_list.append(self)
self.is_on = False
self.btn = btn
self.label = label
@ -235,6 +237,7 @@ class Button:
self.is_on = is_on
def _event_cb_adapter(self, e):
print("btn event:", self.label.get_text())
self.event_cb(self, e)
def add_event_cb(self, event_cb, event_type, user_data=None):
@ -501,8 +504,7 @@ def main():
keyboard_btn = Button(status_bar, label_text="keyboard")
keyboard_btn.align(lv.ALIGN.RIGHT_MID, -20, 0)
keyboard_btn.set_size(60, 30)
global_dict["keyboard_btn"] = keyboard_btn
keyboard_btn.add_event_cb(kb_btn_event_cb, lv.EVENT.CLICKED, None)
keyboard_btn.add_event_cb(kb_btn_event_cb, lv.EVENT.ALL, None)
# 创建一个tabview对象
tabview = lv.tabview(lv.scr_act(), lv.DIR.TOP, TABVIEW_HEIGHT)
@ -549,7 +551,6 @@ def main():
tab1_process_bar = BtnProcessBar(tab1, label_text="start")
tab1_process_bar.align(lv.ALIGN.BOTTOM_LEFT, 0, 0)
tab1_process_bar.add_event_cb(tab1_btnbar1_event_cb, lv.EVENT.CLICKED)
global_dict["tab1_process_bar"] = tab1_process_bar
# tab2
timer_segment.align(lv.ALIGN.BOTTOM_RIGHT, -220, -20)
@ -589,7 +590,7 @@ def main():
main()
for i in range(10):
for i in range(1):
time.sleep(0.1)
lv.task_handler()

View File

@ -2,4 +2,4 @@
#define PIKA_VERSION_MINOR 13
#define PIKA_VERSION_MICRO 1
#define PIKA_EDIT_TIME "2024/01/04 20:20:09"
#define PIKA_EDIT_TIME "2024/01/04 21:31:22"