custom widgets#

In addition to the subclasses to the standart QWidgets, some custom widgets are defined.

class configwidgets.ConfigPathWidget(*args, **kwargs)#

A combination of ConfigLineEdit, a QToolButton and a QLabel. Select and display a path. Without setup this mimics a QLineEdit. A QSettings instance can be setup to maintain state between program restarts. The button can be used to start a QFileDialog for easy selection.

__init__(*args, **kwargs)#
setup(config: QSettings, name: str, default: Path = None, label: str = None, mode: str = 'directory')#

Setup the link to a QSettings instance and connect the select function to the button.

Parameters:
  • config (QSettings) – The QSettings instance, that shall be connected.

  • name (str) – The key to store the state of this widget.

  • default (Path, optional) – A default path. The default is None.

  • label (str, optional) – The label would be shown infront of the lineEdit. The default is None.

  • mode (str, optional) – Choose ‘file’ or ‘directory’ as selection mode. In ‘file’ mode a filter can be set. The default is “directory”.

set_label(label: str = None)#

set the label of the widget.

set_mode(mode: str = 'directory', filetypfilter: FileTypeFilter = FileTypeFilter.empty)#

Set the selection mode of the widget. When choosing ‘file’, a filter can be set.

Parameters:
  • mode (str, optional) – Select “directory” or “file”. The default is “directory”.

  • filetypfilter (FileTypeFilter, optional) – Choos a filter. The default is FileTypeFilter.empty.

set_filter(filetypfilter: FileTypeFilter = FileTypeFilter.empty)#

Manualy set the filter of the widget.

set_value(path: Path) pathlib.Path | None#

set a path to be stored. “None” is a valid parameter as well as return value.

reset_value() None#

reset the stored path to ‘None’.

load_value() pathlib.Path | None#

load the stored path. If no valid value is stored the widget resets.

collect() pathlib.Path | None#

save the wiget state.

select_path() Path#

open a QFileDialog to select a path.