8.2.5. The CustomApp base class

CustomApp([parent, tree, title, toolbar, ...])

Base Class to ease the implementation of User Interfaces

class pymodaq_gui.utils.custom_app.CustomApp(parent=None, tree=None, title=None, toolbar=None, create_app_toolbar=True, add_toolbar_break=True, create_app_menu=False, h5_actions_not=(FileAction.CLOSE_FILE, FileAction.OPEN_FILE))[source]

Base Class to ease the implementation of User Interfaces

Inherits the MixIns ActionManager and ParameterManager classes. You have to subclass some methods and make concrete implementation of a given number of methods:

Other methods to reimplement, related to Parameter management

  • value_changed: non mandatory, see pymodaq.utils.managers.parameter_manager.ParameterManager

  • child_added: non mandatory, see pymodaq.utils.managers.parameter_manager.ParameterManager

  • param_deleted: non mandatory, see pymodaq.utils.managers.parameter_manager.ParameterManager

Depending on the object type, the mainwindow and dockarea attributes may be None

if parent is:

  • None or QWidget, the attributes will be
    • parent = QWidget

    • maindow = None

    • dockarea = None

  • DockArea, the attributes will be
    • parent = DockArea

    • maindow = QMainWindow

    • dockarea = DockArea

  • QMainWindow, the attributes will be
    • parent = QMainWindow

    • maindow = QMainWindow

    • dockarea = None

Variables:
  • title (str) – Get/set the app title

  • parent (QWidget, QMainWindow or DockArea)

  • mainwindow (QMainWindow) – the parent QMainWindow

  • dockarea (DockArea) – The underlying DockArea (as central widget of the QMainWindow)

  • menubar (QMenuBar) – The QMainWindow menubar

  • statusbar (QStatusBar) – The QMainWindow statusbar

  • splash_sc (QSplashScreen) – A splash screen to be used to display information

  • get_theme (method) – Returns the current QApplication theme, see qt_themes package

Parameters:

parent (Union[DockArea, QMainWindow, QWidget, None])

tree: ParameterTree

an optional Custom ParameterTree

title: str

The title of the Application instance

toolbar: QTtWidgets.QToolbar

a toolbar from another parent application

create_app_toolbar: bool

If True (default) will create a default toolbar with the name of the application as reference and title

add_toolbar_break: bool

If True, will add a break in the QToolbarArea before adding the toolbar

create_app_menu: bool

If True (default is False) will create a default menu in the menubar with the name of the application as reference and title

See also

pymodaq.utils.managers.action_manager.ActionManager, pymodaq.utils.managers.parameter_manager.ParameterManager

Attributes:
h5_manager

The manager of the h5 file and of its related actions and status widgets

h5saver

Convenience method to access the h5saver and for backcompatibility

menubar

The menubar of the main window, None if there is no main window

module_and_data_saver

A DataToExportSaver using the h5saver of the app

splash_sc

The splash screen to display information, created at the first access

statusbar

The status bar of the main window (or the one of this app if it has no main window)

thread_manager

The manager of the worker threads of this app

title

The title of the app (the name of the class if it has been set to None)

Methods

apply_size_hint()

Resize the main window (or the parent widget) to the size hint of the app

connect_things()

Connect actions and/or other widgets signal to methods

delete_actions()

Schedule the deletion of the QActions of this app, including the ones of its H5Manager

do_things_after_ui_setup()

Method to be reimplemented in order to do things after the UI setup

enable_workflow_actions([enable, excepted, ...])

Enable/Disable workflow actions (start, stop, pause) + other specified ones

get_help_markdown()

Markdown text describing how to use this application, shown by the Help action

get_local_folder([user])

Create a local User or system wide folder to store things about this extension

get_theme([name])

Returns the theme named name, or the current one if None (see the qt_themes package)

insert_custom_status_widgets()

create here Widgets to be added to the StatusBar To be reimplemented

populate_status_bar()

Generic method to populate the Status Bar

quit_fun()

Method to be reimplemented in order to define a custom quit function

set_permanent_status(status)

Display a permanent status message

setup_actions()

Method where to create actions.

setup_docks()

deprecated, see setup_docks_and_widgets

setup_docks_and_widgets()

Method to be reimplemented to set up the docks layout and/or widgets

setup_menu([menubar])

Deprecated, use setup_menus_and_toolbars

setup_menus_and_toolbars([menubar])

Non-mandatory method to be subclassed in order to create menus and toolbars

setup_ui()

Build the UI: docks and widgets, menus, toolbars, actions and connections (calls the hooks in order)

setup_workflow_actions()

Create the start, stop, pause and log actions (in the actions menu), see WorkFlowActions

update_status(message[, wait_time])

Show the message in the status bar with a delay of wait_time ms.

log_signal

classmethod get_local_folder(user=False)[source]

Create a local User or system wide folder to store things about this extension

Return type:

Path

static get_theme(name=None)[source]

Returns the theme named name, or the current one if None (see the qt_themes package)

Return type:

Theme

apply_size_hint()[source]

Resize the main window (or the parent widget) to the size hint of the app

Return type:

None

connect_things()[source]

Connect actions and/or other widgets signal to methods

To be reimplemented

Return type:

None

delete_actions()[source]

Schedule the deletion of the QActions of this app, including the ones of its H5Manager

See ActionManager.delete_actions()

Added in version 5.3.9.

Return type:

None

do_things_after_ui_setup()[source]

Method to be reimplemented in order to do things after the UI setup

Return type:

None

enable_workflow_actions(enable=True, excepted=(), opposite=(), other_actions=())[source]

Enable/Disable workflow actions (start, stop, pause) + other specified ones

if an action is specified in excepted, nothing is done on it if an action is specified in opposite, the opposite boolean is applied to its enabled status

Everytime this function is called the Pause action is unchecked

Return type:

None

get_help_markdown()[source]

Markdown text describing how to use this application, shown by the Help action

Read from the help.md (or <module>.help.md) next to the module defining the class, else the class docstring

Return type:

str

insert_custom_status_widgets()[source]

create here Widgets to be added to the StatusBar To be reimplemented

Examples

self._file_open_LED = QLED() self.statusbar.addPermanentWidget(self._file_open_LED)

Return type:

None

populate_status_bar()[source]

Generic method to populate the Status Bar

for customization, reimplement insert_custom_status_widgets method

Return type:

None

quit_fun()[source]

Method to be reimplemented in order to define a custom quit function

Return type:

bool | None

set_permanent_status(status)[source]

Display a permanent status message

Method populate_status_bar should have been called beforehand

Return type:

None

setup_actions()[source]

Method where to create actions.

To be reimplemented

Examples

>>> self.add_action('grab', 'Grab', 'camera', "Grab from camera", checkable=True, menu='file_menu')
>>> self.add_action('load', 'Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera", checkable=False)
>>> self.add_action('save', 'Save' 'SaveAs', "Save current data", checkable=False)

>>>self.affect_to(‘load’, ‘file_menu’) >>>self.affect_to(‘save’, ‘file_menu’)

Return type:

None

setup_docks()[source]

deprecated, see setup_docks_and_widgets

Return type:

None

setup_docks_and_widgets()[source]

Method to be reimplemented to set up the docks layout and/or widgets

Examples

>>>self.docks[‘ADock’] = gutils.Dock(‘ADock name’) >>>self.dockarea.addDock(self.docks[‘ADock’]) >>>self.docks[‘AnotherDock’] = gutils.Dock(‘AnotherDock name’) >>>self.dockarea.addDock(self.docks[‘AnotherDock’’’], ‘bottom’, self.docks[‘ADock’])

Return type:

None

setup_menu(menubar=None)[source]

Deprecated, use setup_menus_and_toolbars

Return type:

None

setup_menus_and_toolbars(menubar=None)[source]

Non-mandatory method to be subclassed in order to create menus and toolbars

create menu and toolbar for actions defined in setup_actions, for instance:

Examples

>>>file_menu = self.add_menu(‘file_menu’, ‘File’, self.menubar) >>>submenu = self.add_menu(‘submenu’, ‘ASubMenu’, ‘file_menu’) >>>file_toolbar = self.add_toolbar(‘file_toolbar’, ‘File’, self.mainwindow)

See also

pymodaq.utils.managers.action_manager.ActionManager

Return type:

None

setup_ui()[source]

Build the UI: docks and widgets, menus, toolbars, actions and connections (calls the hooks in order)

Return type:

None

setup_workflow_actions()[source]

Create the start, stop, pause and log actions (in the actions menu), see WorkFlowActions

Return type:

None

update_status(message, wait_time=None)[source]

Show the message in the status bar with a delay of wait_time ms.

Return type:

None

property h5_manager: H5Manager

The manager of the h5 file and of its related actions and status widgets

property h5saver: H5Saver

Convenience method to access the h5saver and for backcompatibility

property menubar: QMenuBar

The menubar of the main window, None if there is no main window

property module_and_data_saver: DataToExportSaver

A DataToExportSaver using the h5saver of the app

property splash_sc: QSplashScreen

The splash screen to display information, created at the first access

property statusbar: QStatusBar

The status bar of the main window (or the one of this app if it has no main window)

property thread_manager: WorkerThreadManager

The manager of the worker threads of this app

property title: str

The title of the app (the name of the class if it has been set to None)

Setter accepts:

Optional[str]