Action handler#
The datalab.gui.actionhandler module handles all application actions
(menus, toolbars, context menu). These actions point to DataLab panels, processors,
objecthandler, β¦
Utility classes#
- class datalab.gui.actionhandler.SelectCond[source]#
Signal or image select conditions
- static always(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
Always true
- static exactly_one(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
Exactly one signal or image is selected
- static exactly_one_group(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
Exactly one group is selected
- static exactly_one_group_or_one_object(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
Exactly one group or one signal or image is selected
- static at_least_one_group_or_one_object(sel_groups: list[ObjectGroup], sel_objects: list[SignalObj | ImageObj]) bool[source]#
At least one group or one signal or image is selected
- static at_least_one(sel_groups: list[ObjectGroup], sel_objects: list[SignalObj | ImageObj]) bool[source]#
At least one signal or image is selected
- static at_least_two(sel_groups: list[ObjectGroup], sel_objects: list[SignalObj | ImageObj]) bool[source]#
At least two signals or images are selected
- static with_roi(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
At least one signal or image has a ROI
- static exactly_one_with_roi(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
Exactly one signal or image has a ROI
- static exactly_one_with_annotations(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool[source]#
Exactly one signal or image has annotations
Handler classes#
- class datalab.gui.actionhandler.SignalActionHandler(panel: SignalPanel | ImagePanel, panel_toolbar: QW.QToolBar, view_toolbar: QW.QToolBar)[source]#
Object handling signal panel GUI interactions: actions, menus, β¦
- action_for(function_or_name: Callable | str, position: int | None = None, separator: bool = False, context_menu_pos: int | None = None, context_menu_sep: bool = False, toolbar_pos: int | None = None, toolbar_sep: bool = False, toolbar_category: ActionCategory | None = None) QW.QAction#
Create action for a feature.
- Parameters:
function_or_name β function or name of the feature
position β add action to menu at this position. Defaults to None.
separator β add separator before action in menu
context_menu_pos β add action to context menu at this position.
context_menu_pos β add action to context menu at this position. Defaults to None.
context_menu_sep β add separator before action in context menu (or after if context_menu_pos is positive). Defaults to False.
toolbar_pos β add action to toolbar at this position. Defaults to None.
toolbar_sep β add separator before action in toolbar (or after if toolbar_pos is positive). Defaults to False.
toolbar_category β toolbar category. Defaults to None. If toolbar_pos is not None, this specifies the category of the toolbar. If None, defaults to ActionCategory.VIEW_TOOLBAR if the current category is ActionCategory.VIEW, else to ActionCategory.PANEL_TOOLBAR.
- Returns:
New action
- add_action(action: QW.QAction, select_condition: Callable | None = None) None#
Add action to list of actions.
- Parameters:
action β action to add
select_condition β condition to enable action. Defaults to None. If None, action is enabled if at least one object is selected.
- add_to_action_list(action: QW.QAction, category: ActionCategory | None = None, pos: int | None = None, sep: bool = False) None#
Add action to list of actions.
- Parameters:
action β action to add
category β action category. Defaults to None. If None, action is added to the current category.
pos β add action to menu at this position. Defaults to None. If None, action is added at the end of the list.
sep β add separator before action in menu (or after if pos is positive). Defaults to False.
- create_all_actions()#
Create all actions
- has_annotations_in_clipboard(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool#
Check if annotations clipboard is not empty
- has_metadata_in_clipboard(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool#
Check if metadata clipboard is not empty
- new_action(title: str, position: int | None = None, separator: bool = False, triggered: Callable | None = None, toggled: Callable | None = None, shortcut: QW.QShortcut | None = None, icon_name: str | None = None, tip: str | None = None, select_condition: Callable | str | None = None, context_menu_pos: int | None = None, context_menu_sep: bool = False, toolbar_pos: int | None = None, toolbar_sep: bool = False, toolbar_category: ActionCategory | None = None) QW.QAction#
Create new action and add it to list of actions.
- Parameters:
title β action title
position β add action to menu at this position. Defaults to None.
separator β add separator before action in menu (or after if pos is positive). Defaults to False.
triggered β triggered callback. Defaults to None.
toggled β toggled callback. Defaults to None.
shortcut β shortcut. Defaults to None.
icon_name β icon name. Defaults to None.
tip β tooltip. Defaults to None.
select_condition β selection condition. Defaults to None. If str, must be the name of a method of SelectCond, i.e. one of βalwaysβ, βexactly_oneβ, βexactly_one_groupβ, βat_least_one_group_or_one_objectβ, βat_least_oneβ, βat_least_twoβ, βwith_roiβ.
context_menu_pos β add action to context menu at this position. Defaults to None.
context_menu_sep β add separator before action in context menu (or after if context_menu_pos is positive). Defaults to False.
toolbar_pos β add action to toolbar at this position. Defaults to None.
toolbar_sep β add separator before action in toolbar (or after if toolbar_pos is positive). Defaults to False.
toolbar_category β toolbar category. Defaults to None. If toolbar_pos is not None, this specifies the category of the toolbar. If None, defaults to ActionCategory.VIEW_TOOLBAR if the current category is ActionCategory.VIEW, else to ActionCategory.PANEL_TOOLBAR.
- Returns:
New action
- new_category(category: ActionCategory) Generator[None, None, None]#
Context manager for creating a new menu.
- Parameters:
category β Action category
- Yields:
None
Context manager for creating a new menu.
- Parameters:
title β Menu title
icon_name β Menu icon name. Defaults to None.
store_ref β Optional attribute name to store menu reference. Defaults to None.
- Yields:
None
Populate the Results Delete submenu dynamically based on current selection
Populate the ROI Remove submenu dynamically based on current selection
- class datalab.gui.actionhandler.ImageActionHandler(panel: SignalPanel | ImagePanel, panel_toolbar: QW.QToolBar, view_toolbar: QW.QToolBar)[source]#
Object handling image panel GUI interactions: actions, menus, β¦
- action_for(function_or_name: Callable | str, position: int | None = None, separator: bool = False, context_menu_pos: int | None = None, context_menu_sep: bool = False, toolbar_pos: int | None = None, toolbar_sep: bool = False, toolbar_category: ActionCategory | None = None) QW.QAction#
Create action for a feature.
- Parameters:
function_or_name β function or name of the feature
position β add action to menu at this position. Defaults to None.
separator β add separator before action in menu
context_menu_pos β add action to context menu at this position.
context_menu_pos β add action to context menu at this position. Defaults to None.
context_menu_sep β add separator before action in context menu (or after if context_menu_pos is positive). Defaults to False.
toolbar_pos β add action to toolbar at this position. Defaults to None.
toolbar_sep β add separator before action in toolbar (or after if toolbar_pos is positive). Defaults to False.
toolbar_category β toolbar category. Defaults to None. If toolbar_pos is not None, this specifies the category of the toolbar. If None, defaults to ActionCategory.VIEW_TOOLBAR if the current category is ActionCategory.VIEW, else to ActionCategory.PANEL_TOOLBAR.
- Returns:
New action
- add_action(action: QW.QAction, select_condition: Callable | None = None) None#
Add action to list of actions.
- Parameters:
action β action to add
select_condition β condition to enable action. Defaults to None. If None, action is enabled if at least one object is selected.
- add_to_action_list(action: QW.QAction, category: ActionCategory | None = None, pos: int | None = None, sep: bool = False) None#
Add action to list of actions.
- Parameters:
action β action to add
category β action category. Defaults to None. If None, action is added to the current category.
pos β add action to menu at this position. Defaults to None. If None, action is added at the end of the list.
sep β add separator before action in menu (or after if pos is positive). Defaults to False.
- create_all_actions()#
Create all actions
- has_annotations_in_clipboard(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool#
Check if annotations clipboard is not empty
- has_metadata_in_clipboard(selected_groups: list[ObjectGroup], selected_objects: list[SignalObj | ImageObj]) bool#
Check if metadata clipboard is not empty
- new_action(title: str, position: int | None = None, separator: bool = False, triggered: Callable | None = None, toggled: Callable | None = None, shortcut: QW.QShortcut | None = None, icon_name: str | None = None, tip: str | None = None, select_condition: Callable | str | None = None, context_menu_pos: int | None = None, context_menu_sep: bool = False, toolbar_pos: int | None = None, toolbar_sep: bool = False, toolbar_category: ActionCategory | None = None) QW.QAction#
Create new action and add it to list of actions.
- Parameters:
title β action title
position β add action to menu at this position. Defaults to None.
separator β add separator before action in menu (or after if pos is positive). Defaults to False.
triggered β triggered callback. Defaults to None.
toggled β toggled callback. Defaults to None.
shortcut β shortcut. Defaults to None.
icon_name β icon name. Defaults to None.
tip β tooltip. Defaults to None.
select_condition β selection condition. Defaults to None. If str, must be the name of a method of SelectCond, i.e. one of βalwaysβ, βexactly_oneβ, βexactly_one_groupβ, βat_least_one_group_or_one_objectβ, βat_least_oneβ, βat_least_twoβ, βwith_roiβ.
context_menu_pos β add action to context menu at this position. Defaults to None.
context_menu_sep β add separator before action in context menu (or after if context_menu_pos is positive). Defaults to False.
toolbar_pos β add action to toolbar at this position. Defaults to None.
toolbar_sep β add separator before action in toolbar (or after if toolbar_pos is positive). Defaults to False.
toolbar_category β toolbar category. Defaults to None. If toolbar_pos is not None, this specifies the category of the toolbar. If None, defaults to ActionCategory.VIEW_TOOLBAR if the current category is ActionCategory.VIEW, else to ActionCategory.PANEL_TOOLBAR.
- Returns:
New action
- new_category(category: ActionCategory) Generator[None, None, None]#
Context manager for creating a new menu.
- Parameters:
category β Action category
- Yields:
None
Context manager for creating a new menu.
- Parameters:
title β Menu title
icon_name β Menu icon name. Defaults to None.
store_ref β Optional attribute name to store menu reference. Defaults to None.
- Yields:
None
Populate the Results Delete submenu dynamically based on current selection
Populate the ROI Remove submenu dynamically based on current selection