lv_example_style_2.py 499 B

12345678910111213141516171819202122
  1. #
  2. # Using the background style properties
  3. #
  4. style = lv.style_t()
  5. style.init()
  6. style.set_radius(5)
  7. # Make a gradient
  8. style.set_bg_opa(lv.OPA.COVER)
  9. style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 1))
  10. style.set_bg_grad_color(lv.palette_main(lv.PALETTE.BLUE))
  11. style.set_bg_grad_dir(lv.GRAD_DIR.VER)
  12. # Shift the gradient to the bottom
  13. style.set_bg_main_stop(128)
  14. style.set_bg_grad_stop(192)
  15. # Create an object with the new style
  16. obj = lv.obj(lv.scr_act())
  17. obj.add_style(style, 0)
  18. obj.center()