params_interfaces#
- class ChannelUiParameter(tab: QWidget, channel_name: str, *, event_bus: EventBus, name_widget_name: str | None = None, get_view: Callable[[], Mapping[str, Any]] | None = None, apply_patch: Callable[[dict], None] | None = None)[source]#
Bases:
UiParameter,ABCBase class for channel parameters. Each channel parameter is associated with a channel name and a widget in the tab.
- abstract property cfg_subtree: List[str]#
- property name#
- class ChannelsUiParameterCollection(tab: QWidget, *, pipeline_name: str, event_bus: EventBus, get_view: Callable[[], Mapping[str, Any]] | None = None, apply_patch: Callable[[dict], None] | None = None)[source]#
Bases:
UiParameterCollection- property channel_params#
- property channels#
- publishes = <ClearMap.Utils.event_bus.Publishes object>#
- property relevant_channels#
- class EditingFinishedFilter(callback, parent=None)[source]#
Bases:
QObjectEmits a callback when a QPlainTextEdit loses focus (≈ editingFinished).
- class ParamLink(keys: ~typing.List[str] | None, widget: ~PyQt5.QtWidgets.QWidget, object_name: str | None = None, scope_root: ~PyQt5.QtWidgets.QWidget | None = None, default: ~typing.Any | None = None, connect: bool = True, cast_to_ui: ~typing.Callable[[~typing.Any], ~typing.Any] | None = <function identity_op>, cast_from_ui: ~typing.Callable[[~typing.Any], ~typing.Any] | None = <function identity_op>, notify_apply: ~typing.Callable[[], None] | None = None, extra_connect: ~typing.Callable[[~PyQt5.QtWidgets.QWidget, ~typing.Callable[[], None]], ~typing.Callable | None] | None = None, missing_ok: bool = False, present_if: ~typing.Callable[[dict], bool] | None = None, disabled_value: ~typing.Any = None, ui_sentinel: ~typing.Any = None, enforce_sentinel_min=False)[source]#
Bases:
objectA class to link a widget to a config file. This is the object passed in the
params_dictattribute of theUiParameterclass. It is used in the __getattr__ and __setattr__ and __connect_widget methods to link the widget to the config file.Warning
extra_connect needs to return the disconnector function if required.
- keys#
The list of keys to access the value in the config file If None, the attribute is not present in the config file and will not be connected
- Type:
list(str) (optional)
- _widget#
The GUI widget to be connected to the config file
- Type:
QWidget
- object_name#
- Type:
str
- default#
The default value to be used if the value is not found in the config file
- Type:
Any
- connect#
A function to call to do the binding between the widget and the corresponding section of the config file or a boolean to indicate whether the widget should be connected to the config file. If set to True, the widget will be connected automatically by simply updating the value in the config file. For more complex widgets, a function can be passed to handle the connection. Set to False to not connect or connect manually.
- Type:
function | bool
- cast_from_ui: Callable[[Any], Any] | None#
- cast_to_ui: Callable[[Any], Any] | None#
- connect: bool#
- default: Any | None#
- keys: List[str]#
- missing_ok: bool#
- object_name: str | None#
- present_if: Callable[[dict], bool] | None#
- scope_root: QWidget | None#
- property widget#
- class UiParameter(tab: QWidget, *, event_bus: EventBus, get_view: Callable[[], Mapping[str, Any]] | None = None, apply_patch: Callable[[dict], None] | None = None)[source]#
Bases:
BusSubscriberMixinThis is a class to link the GUI widgets to the config file. This is done automatically from parsing the
params_dictattribute. Theparams_dictattribute is a dictionary of the form:{'attr_name': ParamLink(keys, widget, attr_name=, default=, connect=)} or {'attr_name': keys,}
where:
attr_nameis the name of the attribute in the classkeysis a list of keys (chain) to access the value in the config file.
If
None, the attribute is not connected widget is the GUI widgetconnectis a boolean to indicate whether the widget should be connected to the config file. Set toFalseto not connect or connect manually. If the value is not aParamLink, it is assumed that the keys point to the value and the widget connection is done through accessors and mutators.- tab#
The tab where the widget is located
- Type:
QWidget
- params_dict#
The dictionary of attributes and their corresponding ParamLink
- Type:
Dict[str, ParamLink | List[str]
- _cfg_subtree#
The list of keys to access the config file. This allows a relative path to be used from the whole config file.
- Type:
List[str]
- bind_apply_patch(fn: Callable[[dict], None]) None[source]#
Provide a sink to apply a patch (already scoped to the section).
- bind_view_provider(fn: Callable[[], Mapping[str, Any]]) None[source]#
Provide a readonly view of the current section (fresh each call).
- extend_params_dict(extra_param_links: dict[str, ParamLink | list], *, connect_new: bool = True)[source]#
Extend the params_dict with new entries after creation (and potenitally after initaial connexion)
- Parameters:
extra_param_links (dict[str, ParamLink | list]) – The new entries to add to the params_dict
connect_new
Returns
- handle_widget_changed(*_, attr_name='', **__)[source]#
Generic handler for simple widgets that binds them to the config file. Calls _emit_patch with the keys obtained from the ParamLink with attr_name and the current value of the attribute. Discards the values of the signal passed by Qt.
- Parameters:
attr_name (str) – The name of the attribute in the class
- sanitize_neg_one(val)[source]#
In python, the maximum item (last item) in a list can be accessed with -1. In ClearMap, the maximum is often represented by None. This function is used to do the conversion.
- Parameters:
val (int) – The value to be converted
Returns
- int or None
The converted value
- sanitize_nones(val)[source]#
In python, the maximum item (last item) in a list can be accessed with -1. In ClearMap, the maximum is often represented by None. This function is used to do the conversion.
- Parameters:
val (int or None) – The value to be converted
Returns
- int
The converted value
- advanced_controls: List[QWidget]#
- property cfg_subtree: List[str]#
- tab: QWidget#
- property view#
- class UiParameterCollection(tab: QWidget, *, pipeline_name: str, event_bus: EventBus, get_view: Callable[[], Mapping[str, Any]] | None = None, apply_patch: Callable[[dict], None] | None = None)[source]#
Bases:
BusSubscriberMixin,ABCFor multi-section UiParameters that share the same config file. This ensures the file remains consistent. Although the attributes of contained UiParameters are accessible, it is recommended to first dereference them to avoid clashes.
- bind_apply_patch(fn: Callable[[dict], None]) None[source]#
Provide a sink to apply a patch (already scoped to the section).
- bind_view_provider(fn: Callable[[], Mapping[str, Any]]) None[source]#
Provide a readonly view of the current section (fresh each call).
- advanced_controls: List[QWidget]#
- cfg_subtree: List[str]#
- abstract property params: list[UiParameter]#
- property version#
- property view#
- class VectorLink(keys: Sequence[str], widget: QFrame, *, disable_globally: bool | str = 'auto', disabled_value: str | None = None, cast_to_ui: Callable[[Any], Any] | None = None, cast_from_ui: Callable[[Any], Any] | None = None, collapse_singular: bool = True, enforce_sentinel_min: bool = True, n: int | None = None, dtype: Callable[[Any], Any] | str = 'auto', ui_sentinel: int | float = -1, default_on_enable=None, notify_apply: Callable[[], None] | None = None, extra_connect: Callable[[QFrame, Callable[[], None]], None] | None = None, show_sentinel_when_off: bool = False)[source]#
Bases:
ParamLink- property dtype#
- property has_global_toggle#
- property n_numbers#
- class WidgetOps[source]#
Bases:
objectRegistry + cache for widget getters/setters/connectors.
- register(cls: Type[QWidget], *, getter: Callable[[QWidget], Any] | None = None, setter: Callable[[QWidget, Any], None] | None = None, connector: Callable[[QWidget, Callable[[], None]], None] | None = None) None[source]#
Register operations for a given widget class. If an operation is None, it will not be registered. This will clear the cache which will be rebuilt on demand.
- Parameters:
cls (Type[QWidget]) – The widget class to register
getter (Getter) – The getter function for the widget class
setter (Setter) – The setter function for the widget class
connector (Connector) – The connector function for the widget class
- resolve(widget: QWidget) Tuple[Callable[[QWidget], Any] | None, Callable[[QWidget, Any], None] | None, Callable[[QWidget, Callable[[], None]], None] | None][source]#
Resolve the operations for a given widget instance. Uses the class of the widget to lookup the operations. This will also use MRO to find the most specific registered operations. Caches the results for faster lookup next time.
- Parameters:
widget (QWidget) – The widget instance to resolve the operations for
Returns
- OpsTuple
A tuple of (getter, setter, connector) functions or None if not found
- frame_getter(widget: QFrame)[source]#
For compound objects wrapped in a frame like singlets, doublets and triplets, with or without a checkbox or for text edits with an enable checkbox
- frame_setter(widget: QFrame, value)[source]#
For compound objects wrapped in a frame like singlets, doublets and triplets, with or without a checkbox or for text edits with an enable checkbox
- n_proc_connector(widget: NProcessesWidget, cb)[source]#
- n_proc_getter(widget: NProcessesWidget)[source]#
- n_proc_setter(widget: NProcessesWidget, value)[source]#
- optional_text_link(keys: Sequence[str], widget: QFrame, disabled_value: str | None = None) ParamLink[source]#
Create a ParamLink for an optional text field. This is a QFrame widgets that contain a text editable (QLineEdit or QPlainTextEdit) and an enable/disable checkbox.
- Parameters:
keys (List[str]) – The keys for the config
widget (QFrame) – The QFrame widget containing the text edit and checkbox
disabled_value (Optional[Union[str, None]]) – The value to be used when the widget is disabled. If None, the config value will be None when disabled. If “auto”, the config value will be “auto” when disabled. Default is None.
Returns
- ParamLink
The ParamLink object to be used in the params_dict