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.
- Paramètres:
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.
- Renvoie:
New action
- add_action(action: QW.QAction, select_condition: Callable | None = None) None#
Add action to list of actions.
- Paramètres:
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.
- Paramètres:
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.
- Paramètres:
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.
- Renvoie:
New action
- new_category(category: ActionCategory) Generator[None, None, None]#
Context manager for creating a new menu.
- Paramètres:
category – Action category
- Yields:
None
Context manager for creating a new menu.
- Paramètres:
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.
- Paramètres:
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.
- Renvoie:
New action
- add_action(action: QW.QAction, select_condition: Callable | None = None) None#
Add action to list of actions.
- Paramètres:
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.
- Paramètres:
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.
- Paramètres:
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.
- Renvoie:
New action
- new_category(category: ActionCategory) Generator[None, None, None]#
Context manager for creating a new menu.
- Paramètres:
category – Action category
- Yields:
None
Context manager for creating a new menu.
- Paramètres:
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