Skip to content

add_item_visible_handler on table column not firing #2587

@BinaryDustFF

Description

@BinaryDustFF

Version of Dear PyGui

Version: 2.1.0
Operating System: Windows 10

My Issue/Question

I'm having an issue with the visibility handler not firing on table columns.
In a table with hideable=True and several columns, when I hide a column with the mouse-click context menu, the column disappears and the visible property of the column updates from True to False (confirmed with the item registry debugger). Everything is fine there.
Let say I want to propagate this visibility state elsewhere, I created an item_handler_registry with add_item_visible_handler inside it, and a callback to update something elsewhere. Now the problems begins.

First, the main subject of this issue, I can't get the item_visible_handler to work on table columns, the callback is never called regardless of the visible state of the column. In the example bellow, two exact same handler registries have been created, but only the one bound to the text item is firing.
Am I missing something?

Also (but this is a feature request), a handler to handle visibility updates would be nice! Currently, the callback is fired at every frame for every visible bound item. In my case, I only need to know when the visibility state of items changes. I can easily work around that, but it would be very nice.

To Reproduce

Steps to reproduce the behavior:

  1. Execute the example bellow

Expected behavior

The callback is fired from the text item handler, but never from the column item handler.

Screenshots/Video

Image

Standalone, minimal, complete and verifiable example

from dearpygui import dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

############# Event handlers
def visible_cb(s, ad, ud):
  # ad will contain the item ID in future release
  print(f"{ud} is visible")

with dpg.item_handler_registry() as visible_col_handler:
  dpg.add_item_visible_handler(callback=visible_cb, user_data="column")
with dpg.item_handler_registry() as visible_item_handler:
  dpg.add_item_visible_handler(callback=visible_cb, user_data="item")

############# Window and content
first = True
with dpg.window(label="tutorial"):
  with dpg.table(
    hideable=True, # Allow columns to be hiden
    header_row=True
  ):
    # Create 4 columns
    cols = ("this", "is", "a", "test")
    for colIter in cols:
      id = dpg.add_table_column(label=colIter)
      if first:
        first = False
        dpg.bind_item_handler_registry(id, visible_col_handler)
    
    first = True
    # Create 3 rows
    rows = [("#")*4]*3
    for rowIter in rows:
      with dpg.table_row():
        for valIter in rowIter:
          id = dpg.add_text(valIter)
          if first:
            first = False
            dpg.bind_item_handler_registry(id, visible_item_handler)

############# App start
dpg.show_viewport()
dpg.show_item_registry()
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