DearPyGui
DearPyGui copied to clipboard
Let `dpg.disable_item` use the tag of a `dpg.group` to disable all children
It would be nice if dpg.enable_item
and dpg.disable_item
could work when you pass it the tag of a dpg.group
. Like how you can do with dpg.show_item
and dpg.hide_item
.
My current method requires using dpg.get_item_children
to get the tags of the children and then using a for loop.
Below is a MWE of the differences between enable/disable and show/hide.
import dearpygui.dearpygui as dpg
import itertools
dpg.create_context()
def enabled(sender, app_data):
for tag in itertools.chain(*dpg.get_item_children("foo").values()):
dpg.enable_item(tag) if app_data else dpg.disable_item(tag)
def hide(sender, app_data):
dpg.hide_item("foo") if app_data else dpg.show_item("foo")
with dpg.window():
dpg.add_checkbox(label="Enabled", default_value=True, callback=enabled)
dpg.add_checkbox(label="Hide", default_value=False, callback=hide)
with dpg.group(tag='foo'):
dpg.add_button(label='Button1',callback=lambda: print('Button1'))
dpg.add_button(label='Button2',callback=lambda: print('Button2'))
dpg.create_viewport(width=200, height=200)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()