2021-06-07 13:56:08 +02:00
|
|
|
def event_handler(e):
|
|
|
|
code = e.get_code()
|
|
|
|
obj = lv.dropdown.__cast__(e.get_target())
|
|
|
|
if code == lv.EVENT.VALUE_CHANGED:
|
2021-02-08 09:53:03 +01:00
|
|
|
option = " "*10 # should be large enough to store the option
|
|
|
|
obj.get_selected_str(option, len(option))
|
|
|
|
# .strip() removes trailing spaces
|
|
|
|
print("Option: \"%s\"" % option.strip())
|
|
|
|
|
2021-06-07 13:56:08 +02:00
|
|
|
# Create a normal drop down list
|
|
|
|
dd = lv.dropdown(lv.scr_act())
|
|
|
|
dd.set_options("\n".join([
|
|
|
|
"Apple\n"
|
|
|
|
"Banana\n"
|
|
|
|
"Orange\n"
|
|
|
|
"Cherry\n"
|
|
|
|
"Grape\n"
|
|
|
|
"Raspberry\n"
|
|
|
|
"Melon\n"
|
|
|
|
"Orange\n"
|
|
|
|
"Lemon\n"
|
|
|
|
"Nuts\n"]))
|
|
|
|
|
|
|
|
dd.align(lv.ALIGN.TOP_MID, 0, 20)
|
|
|
|
dd.add_event_cb(event_handler, lv.EVENT.ALL, None)
|
2021-02-08 09:53:03 +01:00
|
|
|
|