Indication when tab has been closed #2163
Unanswered
jackson-bland
asked this question in
Support
Replies: 1 comment 1 reply
-
I've also been struggling to find a way to do this. The closest I've been able to get is to add a callback to the tab bar: from dearpygui import dearpygui as dpg
def on_tab_changed():
active_tab = dpg.get_value('tab_bar')
print('Active tab:', active_tab)
for tab in dpg.get_item_children('tab_bar')[1]:
if not dpg.is_item_visible(tab):
print('This tab was closed:', tab)
dpg.delete_item(tab)
dpg.create_context()
dpg.create_viewport()
with dpg.window():
with dpg.tab_bar(callback=on_tab_changed, tag='tab_bar'):
dpg.add_tab(label='Tab 1', closable=True)
dpg.add_tab(label='Tab 2', closable=True)
dpg.add_tab(label='Tab 3', closable=True)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() But there is no callback for when the last tab is closed, and no callback if you close a tab that isn't focused. I'm unsure how to deal with this. Currently I just have one empty, uncloseable tab to make sure there is always at least one tab, which deals with the first scenario. The order of the tabs is also not updated in the list provided by |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Wondering if there is any way to let the program know when a tab has been closed. For example I have two windows and one contains a number of tabs. When one tab is selected, accompanying data is showed on the other window. But when I close the tab I want the other window to also be cleared of that tabs data so I need something similar to a windows "on_close" feature for tabs. I know this doesn't exist withing the tab arguments but wondering if there is any other way (no matter how out of the box / unconventional) to do this.
Beta Was this translation helpful? Give feedback.
All reactions