I have a relatively complex DockArea with with multiple tabs, dock bars, etc. When a particular action is performed (i.e., plotting some data), I want to ensure that the DockItem containing the plot is visible. If the plot is in a TabLayout, I'd like to bring it to the front. Right now, my approach is a bit crude:
def reveal_item(dock_area, item_name):
for parent, item in dock_area.layout.traverse():
if isinstance(item, ItemLayout) and item.name == item_name:
if isinstance(parent, TabLayout):
parent.index = parent.items.index(item)
deferred_call(dock_area.apply_layout, dock_area.layout)
elif isinstance(parent, DockBarLayout):
op = ExtendItem(item=item.name)
deferred_call(dock_area.update_layout, op)
Is this a decent approach? The other issue is that two out of five tabs are releavant to the plot (e.g., each shows a different aspect of the data being plotted). So, if the user is already viewing one of these two tabs, I don't want to force-switch the user to the other tab. How can I find out if the DockItem is visible and/or currently selected? The TabLayout.index does not update when the user switches to a different tab.
Thanks!
Brad