8.5.3.2. pymodaq_gui.managers.config_manager module

class pymodaq_gui.managers.config_manager.ConfigManager(config_path='', msgbox=False)[source]

Bases: ParameterManager

Manager class for handling configuration files and parameters.

Provides functionality to create, load, modify, and save configuration files in XML format with a graphical user interface.

title

Display title for the configuration manager

Type:

str

name

Internal name for the configuration manager

Type:

str

config_path

Path to the directory containing config files

Type:

Path

Methods

make_config()

Create additional configuration parameters.

save_config([overwrite])

Save the current configuration to an XML file.

set_config_from_file(file_path[, show])

Load an existing configuration from an XML file.

set_new_config([file, show])

Create a new configuration with default parameters.

show_config([widget, overwrite])

Display the configuration dialog for viewing and editing settings.

make_config()[source]

Create additional configuration parameters.

Method to be subclassed to add custom parameters specific to the configuration needs of derived classes.

Returns:

List of parameter dictionaries to be added to the configuration.

Empty list in base implementation.

Return type:

list

save_config(overwrite=False)[source]

Save the current configuration to an XML file.

Saves the settings to an XML file in the config_path directory using the filename specified in the settings. If the file already exists and overwrite is False, prompts the user for confirmation before overwriting.

Parameters:

overwrite (bool, optional) – If True, overwrites existing files without prompting. If False, asks for user confirmation before overwriting. Defaults to False.

Returns:

True if the file was successfully saved, False otherwise.

Return type:

bool

Note

The filename is retrieved from the ‘filename’ parameter in settings. The file is saved with a .xml extension in the config_path directory.

set_config_from_file(file_path, show=True)[source]

Load an existing configuration from an XML file.

Reads an XML configuration file and populates the settings tree with the parameters from the file.

Parameters:
  • file_path (Path) – Path to the XML configuration file to load.

  • show (bool, optional) – If True, displays the configuration dialog after loading. Defaults to True.

Note

If file_path is not a Path object, it will be converted to one. Only XML files are supported.

set_new_config(file=None, show=True)[source]

Create a new configuration with default parameters.

Opens a dialog allowing the user to set up a new configuration file with a filename and any additional parameters defined in make_config().

Parameters:

file (str) – Default filename for the new config. If None, uses “{title}_default”. Defaults to None.

show_config(widget=None, overwrite=False)[source]

Display the configuration dialog for viewing and editing settings.

Creates and shows a modal dialog containing the settings tree with Save and Cancel buttons. If the user clicks Save, the configuration is saved to file.

Parameters:
  • widget (QWidget, optional) – Additional widget to include in the dialog layout. Defaults to None.

  • overwrite (bool, optional) – If True, overwrites existing files without prompting. Defaults to False.

Returns:

True if the file was successfully saved, False otherwise.

Return type:

bool

name = 'config'
title = 'Config'