hello,
i use the nice lvgl Lib to do That.
create personalized button
add event on the button
example :
from m5stack import *
from m5stack_ui import *
from uiflow import *
import lvgl as lv
screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0x00000)
lv.init()
# create screen
scr = lv.obj()
# set Background screen
scr.set_style_local_bg_color(scr.PART.MAIN, lv.STATE.DEFAULT, lv.color_hex(0x000000))
# create button
btn = lv.btn(scr)
btn.set_size(80, 80)
# change style
btn.set_style_local_bg_color(scr.PART.MAIN,lv.STATE.DEFAULT, lv.color_hex(0x0000ff))
styleButton = lv.style_t() # create style
styleButton.set_bg_color(lv.STATE.DEFAULT, lv.color_hex(0x0000ff))
styleButton.set_radius(lv.STATE.DEFAULT, 0);
styleButton.set_border_color(lv.STATE.DEFAULT, lv.color_hex(0x0000ff))
btn.add_style(btn.PART.MAIN,styleButton) #define this style
# callback action
def action(btn, event):
global src
if(event == lv.EVENT.CLICKED):
btn.set_style_local_bg_color(btn.PART.MAIN, lv.STATE.DEFAULT, lv.color_hex(0xffffff))
btn.set_style_local_border_color(btn.PART.MAIN, lv.STATE.DEFAULT, lv.color_hex(0xffffff))
# define callback
btn.set_event_cb(action)
# load the screen
lv.scr_load(scr)
best regards
Thomas