Action handler#
The cdl.core.gui.actionhandler
module handles all application actions
(menus, toolbars, context menu). These actions point to DataLab panels, processors,
objecthandler, …
Utility classes#
- class cdl.core.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 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
Handler classes#
- class cdl.core.gui.actionhandler.SignalActionHandler(panel: SignalPanel | ImagePanel, panel_toolbar: QW.QToolBar, view_toolbar: QW.QToolBar)[source]#
Object handling signal panel GUI interactions: actions, menus, …
- add_action(action: 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: 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
- new_action(title: str, position: int | None = None, separator: bool = False, triggered: Callable | None = None, toggled: Callable | None = None, shortcut: 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) 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.
- Yields:
None
- class cdl.core.gui.actionhandler.ImageActionHandler(panel: SignalPanel | ImagePanel, panel_toolbar: QW.QToolBar, view_toolbar: QW.QToolBar)[source]#
Object handling image panel GUI interactions: actions, menus, …
- add_action(action: 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: 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
- new_action(title: str, position: int | None = None, separator: bool = False, triggered: Callable | None = None, toggled: Callable | None = None, shortcut: 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) 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.
- Yields:
None