acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_example_slider_2.py (1669B)
1 # 2 # Show how to style a slider. 3 # 4 # Create a transition 5 props = [lv.STYLE.BG_COLOR, 0] 6 transition_dsc = lv.style_transition_dsc_t() 7 transition_dsc.init(props, lv.anim_t.path_linear, 300, 0, None) 8 9 style_main = lv.style_t() 10 style_indicator = lv.style_t() 11 style_knob = lv.style_t() 12 style_pressed_color = lv.style_t() 13 style_main.init() 14 style_main.set_bg_opa(lv.OPA.COVER) 15 style_main.set_bg_color(lv.color_hex3(0xbbb)) 16 style_main.set_radius(lv.RADIUS.CIRCLE) 17 style_main.set_pad_ver(-2) # Makes the indicator larger 18 19 style_indicator.init() 20 style_indicator.set_bg_opa(lv.OPA.COVER) 21 style_indicator.set_bg_color(lv.palette_main(lv.PALETTE.CYAN)) 22 style_indicator.set_radius(lv.RADIUS.CIRCLE) 23 style_indicator.set_transition(transition_dsc) 24 25 style_knob.init() 26 style_knob.set_bg_opa(lv.OPA.COVER) 27 style_knob.set_bg_color(lv.palette_main(lv.PALETTE.CYAN)) 28 style_knob.set_border_color(lv.palette_darken(lv.PALETTE.CYAN, 3)) 29 style_knob.set_border_width(2) 30 style_knob.set_radius(lv.RADIUS.CIRCLE) 31 style_knob.set_pad_all(6) # Makes the knob larger 32 style_knob.set_transition(transition_dsc) 33 34 style_pressed_color.init() 35 style_pressed_color.set_bg_color(lv.palette_darken(lv.PALETTE.CYAN, 2)) 36 37 # Create a slider and add the style 38 slider = lv.slider(lv.scr_act()) 39 slider.remove_style_all() # Remove the styles coming from the theme 40 41 slider.add_style(style_main, lv.PART.MAIN) 42 slider.add_style(style_indicator, lv.PART.INDICATOR) 43 slider.add_style(style_pressed_color, lv.PART.INDICATOR | lv.STATE.PRESSED) 44 slider.add_style(style_knob, lv.PART.KNOB) 45 slider.add_style(style_pressed_color, lv.PART.KNOB | lv.STATE.PRESSED) 46 47 slider.center() 48