custom widgets#
In addition to the subclasses to the standart QWidgets, some custom widgets are defined.
- class configwidgets.ConfigPathWidget(*args, **kwargs)#
A combination of
QComboBox, a QToolButton and a QLabel. Select and display a path. Without setup this mimics a QComboBox. 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)#
initializing widget, mimics a QComboBox.
- setup(config: QSettings, name: str, default: Path = None, label: str = None, mode: str = None, filetyp=None)#
Setup the connection to a QSettings instance to store state under the key. Optional: Set a default value. Optional: set a visual label. If mode is set to ‘file’ or ‘directory’ a selection button is enabled. If filetyp is set, a filter is used for the selection dialog.
- Parameters:
config (QSettings) – The QSettings Instance.
name (TYPE) – The key to store the data.
default (Path, optional) – The default Path. The default is None.
label (str, optional) – A visual label for the widget. The default is None.
mode (str, optional) – Set to ‘file’ or ‘directory’ to use selection dialog. The default is None.
filetyp (TYPE, optional) – A filter for the selection dialog. The default is None.
- set_label(label: str = None)#
set the label of the widget.
- set_style(style)#
set the style to valid/invalid/not set
- set_mode(mode: str = None, filetyp=None)#
set the selection mode to ‘file’/’directory’. Optional: set a filter.
- set_filetyp(filetyp: FileTypeFilter = FileTypeFilter.empty)#
Set a filter typ for the selection dialog.
- set_icon(icon)#
set the icon of the selection button.
- validate_text(text) pathlib.Path | None#
check if text is a valid path. If valid the value gets stored, else only the display shows the string. Changes the style accordingly.
- load_value() pathlib.Path | None#
load text from config.
- set_empty()#
set value to None.
- set_value(path) pathlib.Path | None#
set value to config and ui.
- collect() pathlib.Path | None#
collect value from ui to config.
- select()#
open a
QFileDialogto select a path.
- class configwidgets.path.FileTypeFilter(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
a class to define filter types.