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_table_1.py (1800B)
1 def draw_part_event_cb(e): 2 obj = e.get_target() 3 dsc = lv.obj_draw_part_dsc_t.__cast__(e.get_param()) 4 # If the cells are drawn../ 5 if dsc.part == lv.PART.ITEMS: 6 row = dsc.id // obj.get_col_cnt() 7 col = dsc.id - row * obj.get_col_cnt() 8 9 # Make the texts in the first cell center aligned 10 if row == 0: 11 dsc.label_dsc.align = lv.TEXT_ALIGN.CENTER 12 dsc.rect_dsc.bg_color = lv.palette_main(lv.PALETTE.BLUE).color_mix(dsc.rect_dsc.bg_color, lv.OPA._20) 13 dsc.rect_dsc.bg_opa = lv.OPA.COVER 14 15 # In the first column align the texts to the right 16 elif col == 0: 17 dsc.label_dsc.flag = lv.TEXT_ALIGN.RIGHT 18 19 # Make every 2nd row grayish 20 if row != 0 and (row % 2) == 0: 21 dsc.rect_dsc.bg_color = lv.palette_main(lv.PALETTE.GREY).color_mix(dsc.rect_dsc.bg_color, lv.OPA._10) 22 dsc.rect_dsc.bg_opa = lv.OPA.COVER 23 24 25 table = lv.table(lv.scr_act()) 26 27 # Fill the first column 28 table.set_cell_value(0, 0, "Name") 29 table.set_cell_value(1, 0, "Apple") 30 table.set_cell_value(2, 0, "Banana") 31 table.set_cell_value(3, 0, "Lemon") 32 table.set_cell_value(4, 0, "Grape") 33 table.set_cell_value(5, 0, "Melon") 34 table.set_cell_value(6, 0, "Peach") 35 table.set_cell_value(7, 0, "Nuts") 36 37 # Fill the second column 38 table.set_cell_value(0, 1, "Price") 39 table.set_cell_value(1, 1, "$7") 40 table.set_cell_value(2, 1, "$4") 41 table.set_cell_value(3, 1, "$6") 42 table.set_cell_value(4, 1, "$2") 43 table.set_cell_value(5, 1, "$5") 44 table.set_cell_value(6, 1, "$1") 45 table.set_cell_value(7, 1, "$9") 46 47 # Set a smaller height to the table. It'll make it scrollable 48 table.set_height(200) 49 table.center() 50 51 # Add an event callback to apply some custom drawing 52 table.add_event_cb(draw_part_event_cb, lv.EVENT.DRAW_PART_BEGIN, None) 53