Skip to content

The problem with triggering styles to the table #2602

@Kolhun

Description

@Kolhun

Version of Dear PyGui - 2.1.1

Operating System: Windows 10

My Issue/Question

I updated dearpygui from version 1.11.1 and the theme stopped working normally.

def create_work_table(
    content: dict[Any, Any],
    popup_tag: str | None = None,
    key: Any = None,
) -> None:
    """
    Создаёт или обновляет таблицу с рабочими данными в интерфейсе.

    Args:
        content: словарь с данными для отображения
        popup_tag: тег всплывающего окна (если используется)
        key: дополнительный ключ (не используется в текущей реализации)
    """
    TABLE_TAG = "tagWorkTableInMapTable"
    PARENT_TAG = "TAG_TABLE_WORK" 

    conf.dataFeatureTableWork.clear()
    if dpg.does_item_exist(TABLE_TAG):
        dpg.delete_item(TABLE_TAG)
    with dpg.theme() as table_theme:
        with dpg.theme_component(dpg.mvTable):
            dpg.add_theme_color(dpg.mvThemeCol_HeaderActive, (0, 0, 0, 0), category=dpg.mvThemeCat_Core)
            dpg.add_theme_color(dpg.mvThemeCol_Header, (0, 0, 0, 0), category=dpg.mvThemeCat_Core)

    with dpg.table(header_row=True, no_host_extendX=True, delay_search=True,
                   borders_innerH=True, borders_outerH=True, borders_innerV=True,
                   borders_outerV=True, context_menu_in_body=True, row_background=True,
                   policy=dpg.mvTable_SizingFixedFit, height=260, clipper=True, scrollY=True,
                   tag=TABLE_TAG, parent=TAG_TABLE_WORK, freeze_rows=1) as table:
        dpg.add_table_column(label="№")
        dpg.add_table_column(label="UID")
        dpg.add_table_column(label="Имя")
        dpg.add_table_column(label="Статус")

        for index, (key_item, data) in enumerate(content.items()):
            if should_display_row_table_work(data, index):
                show_content_table_work(data, index)
                get_data_feature(conf.dataFeatureTableWork, data)

    dpg.bind_item_theme(table, table_theme)

Specifically, the problem with applying the theme is that after clicking on a line, the line becomes transparent again without color overlay, this does not happen when building on a new version.

To Reproduce

The problem is related specifically to styles

Expected behavior

When you click on the rows of the table, the background of the row should become transparent again.

Screenshots/Video

Need
Image

Now
Image

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg


def on_row_click(sender, app_data, user_data):
    print(f"Click on row: {user_data}")


dpg.create_context()


with dpg.window(label="Example Table", width=600, height=400):
    with dpg.theme() as table_theme:
        with dpg.theme_component(dpg.mvTable):
            dpg.add_theme_color(dpg.mvThemeCol_HeaderActive, (0, 0, 0, 0), category=dpg.mvThemeCat_Core)
            dpg.add_theme_color(dpg.mvThemeCol_Header, (0, 0, 0, 0), category=dpg.mvThemeCat_Core)
    
    with dpg.table(header_row=True, borders_innerH=True, borders_outerH=True, 
                   borders_innerV=True, borders_outerV=True, 
                   tag="example_table") as table:
        
        dpg.bind_item_theme(table, table_theme)
        

        dpg.add_table_column(label="№")
        dpg.add_table_column(label="Name")
        dpg.add_table_column(label="Status")
        

        test_data = [
            {"id": 1, "name": "Element 1", "status": "Active"},
            {"id": 2, "name": "Element 2", "status": "Inactive"},
            {"id": 3, "name": "Element 3", "status": "Active"},
            {"id": 4, "name": "Element 4", "status": "Inactive"},
            {"id": 5, "name": "Element 5", "status": "Active"},
        ]
        
        for index, data in enumerate(test_data):
            with dpg.table_row():
                for j in range(3):
                    if j == 0:
                        str_name = str(data["id"])
                    elif j == 1:
                        str_name = data["name"]
                    else:
                        str_name = data["status"]
                    
                    dpg.add_selectable(
                        label=str_name, 
                        span_columns=True,
                        user_data=(index, data),
                        callback=on_row_click
                    )

dpg.create_viewport(title="Minimal Table", width=600, height=400)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions