napari_track_edit.application_menus.menu_manager

Classes

MenuManager

Initializes and manages the menu widgets, including show/hide functionality and

Module Contents

class napari_track_edit.application_menus.menu_manager.MenuManager(viewer: napari.Viewer)

Initializes and manages the menu widgets, including show/hide functionality and tracking active widgets.

viewer
tracks_viewer
hidden = False
initialized_menu_widgets: set[str]
visible_menus: set[str]
active_tabs: list[str] = []
menu_widgets: dict[str, qtpy.QtWidgets.QScrollArea]
initialize_menu(menu: dict[str, dict[str, Any]]) → None

Initialize the menu by creating and adding the specified widgets, with robust handling for closed/deleted dock widgets.

destroy_menu_widget(name: str) → None

Destroy a menu widget and everything it holds on to.

Clicking the ‘x’ on a tab calls napari’s remove_dock_widget, which deletes the QDockWidget but leaves the widget behind as a parentless orphan: it stays alive for as long as anything still references it and keeps reacting to TracksViewer signals (rebuilding the tree, re-filling the table) with nothing to show it in. By giving the widget a cleanup method, we can properly disconnect from these signals and remove it.

_on_dock_destroyed(name: str) → None

Call the menu widget’s cleanup method when its dock is destroyed

_find_dock_widget_by_name(name: str) → qtpy.QtWidgets.QScrollArea | None

Find a widget in the dock dock by name, or return None if not found or deleted.

set_tabbar_location(location: str = 'North') → None

Set tabbar location. :param location: :type location: str, one of (North, East, South, West) to map the tabbar to

_create_scroll_wrapper(widget: qtpy.QtWidgets.QWidget) → qtpy.QtWidgets.QScrollArea

Wrap a widget in a QScrollArea to make it scrollable.

_get_foreground_tabs() → list[str]

Get the names of the currently active tabs (dock widgets that are both initialized and currently present in a dock).

set_foreground_tabs(tab_names: list[str]) → None

Set the specified tab to the foreground.

_get_visible_tabs() → set[str]

Get the names of the current foreground tabs

toggle_menu_panel_visibility() → None

Toggle visibility of all active menu widgets.