The C example for lists in the lvgl docs imho directly translates into this python:
def handler(obj, evt):
if evt == lv.EVENT.CLICKED:
print("Button text:", lv.list.get_btn_text(obj));
# also doesn't work: print("Button text:", obj.get_btn_text());
list = lv.list(scr)
list.set_size(200, 190);
list.align(scr, lv.ALIGN.IN_TOP_MID, 0, 0)
list_btn = list.add_btn(None, "test");
list_btn.set_event_cb(handler);
But that doesn’t work as lv.list.get_btn_text() expects a list and not the object created by list.add_btn() obj.get_btn_text() resulting in TypeError: argument should be a 'list' not a 'obj'
. obj.get_btn_text()
also doesn’t work as obj has no attribute ‘get_btn_text’. Calling list.get_btn_text() returns an empty string.
What am I missing?