lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
237 stars 156 forks source link

Ask a question about buttons of the button #337

Closed xulei3388 closed 3 months ago

xulei3388 commented 3 months ago

Ask a question about buttons

Manually set the current status of the button

How to use the lv_btn_set_state instruction in the mpy+lvgl system?

PGNetHun commented 3 months ago

Hello! Every lv_ function can be divided into 2 main groups in MicroPython code:

  1. Class methods: can be used independent from any LVGL object instance, or enums, constants, constructors, etc. For example: lv.button() = create new button, lv.obj.FLAG.HIDDEN = object hidden flag
  2. Instance methods: after LVGL object is created, we can call methods bound to it. For example: lbl.set_text() = set lv.label object's text, btn.set_state() = set a button object's state

Basically wherever you see lv_xxx_yyyy() widget functions in LVGL documentation, you can "translate" those to: xxx.yyyy().

In your case: there is no "set_state" function, but add_state and remove_state on the object:

xulei3388 commented 3 months ago

Best regards, thank you very much!

Your selfless answer!