Skip to content

Question: How to colorize a Table? #406

Description

@jedie

I would like to add color to a table. Can be the color of the text or background of one cell or a complete column.
I tried different ways, without any success, yet.

one idea:

import display_driver
import lvgl as lv

scr = lv.obj()
table = lv.table(scr)
table.set_size(300, 200)

for row in range(3):
    for col in range(3):
        table.set_cell_value(row, col, f"Cell {row},{col}")

style_red = lv.style_t()
style_red.init()
style_red.set_text_color(lv.color_hex(0xFF0000))
style_red.set_bg_color(lv.color_hex(0xFF0000))

table.add_style(style_red, lv.STATE.USER_1)

table.set_cell_ctrl(0, 0, lv.STATE.USER_1)

Tested in https://sim.lvgl.io/v8.3/micropython/ports/javascript/index.html results in:

Traceback (most recent call last):
  File "<stdin>", line 19, in <module>
AttributeError: no such attribute

Line 19 is: table.set_cell_ctrl(0, 0, lv.STATE.USER_1)

Seems that in https://sim.lvgl.io/v9.0/micropython/ports/webassembly/index.html it's the same error, but results in a broken Traceback:

Traceback (most recent call last):
  File "<stdin>", line , in <module>
AttributeError: no such attribute

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions