Button Focused Color V7 Material Theme


I am using lvgl v7 material dark theme but I find incredibly hard to notice which button is selected when using for example an m5stack (esp32 + ili9341+hardware buttons). The halo around the buttons is not noticeable. So I want to change the button color when it is focused.

I was trying to do something like:

style1 = lv.style_t
style1.set_bg_color(lv.STATE.FOCUSED, lv.COLOR.BLUE)

But I get “AttributeError: ‘module’ object has no attribute ‘COLOR’”.

Any idea on how I can achieve this? Also maybe a little change to Material Theme would be welcome, but it might be just me…

Thank you!

The built-in colors aren’t accessible from MicroPython; you will need to use something along the lines of lv.color.hex (I don’t remember the exact name) instead.

1 Like

Like this, for example:

style1 = lv.style_t()
style1.set_bg_color(lv.STATE.FOCUSED, lv.color_hex3(0x00F))

There was a recent discussion about adding colors.py for basic colors.

1 Like

Thank you both! It is now working!