dynamic-settings-widget 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dynamic_settings_widget/__init__.py +56 -0
- dynamic_settings_widget/adapters/__init__.py +42 -0
- dynamic_settings_widget/adapters/base.py +179 -0
- dynamic_settings_widget/adapters/memory.py +201 -0
- dynamic_settings_widget/adapters/runner.py +63 -0
- dynamic_settings_widget/core/__init__.py +1 -0
- dynamic_settings_widget/core/catalog.py +201 -0
- dynamic_settings_widget/core/common.py +214 -0
- dynamic_settings_widget/core/conditions.py +146 -0
- dynamic_settings_widget/core/datatypes.py +414 -0
- dynamic_settings_widget/core/diagnostics.py +69 -0
- dynamic_settings_widget/core/loader.py +101 -0
- dynamic_settings_widget/core/model.py +245 -0
- dynamic_settings_widget/core/overrides.py +353 -0
- dynamic_settings_widget/core/parser.py +552 -0
- dynamic_settings_widget/core/presentation.py +68 -0
- dynamic_settings_widget/core/registry.py +258 -0
- dynamic_settings_widget/core/state.py +314 -0
- dynamic_settings_widget/data/example_catalog.json +23 -0
- dynamic_settings_widget/data/example_layout.json +23 -0
- dynamic_settings_widget/data/settings_catalog.schema.json +388 -0
- dynamic_settings_widget/data/settings_definition.schema.json +1041 -0
- dynamic_settings_widget/data/settings_layout.schema.json +701 -0
- dynamic_settings_widget/data/settings_override.schema.json +406 -0
- dynamic_settings_widget/py.typed +0 -0
- dynamic_settings_widget/session.py +1537 -0
- dynamic_settings_widget/standalone/__init__.py +67 -0
- dynamic_settings_widget/standalone/action_button.py +200 -0
- dynamic_settings_widget/standalone/auth_widget.py +377 -0
- dynamic_settings_widget/standalone/check_box_editor.py +233 -0
- dynamic_settings_widget/standalone/choice_buttons_editor.py +394 -0
- dynamic_settings_widget/standalone/color_editor.py +316 -0
- dynamic_settings_widget/standalone/dropdown_editor.py +356 -0
- dynamic_settings_widget/standalone/editable_label.py +428 -0
- dynamic_settings_widget/standalone/float_spin_box.py +621 -0
- dynamic_settings_widget/standalone/font_editor.py +348 -0
- dynamic_settings_widget/standalone/hotkey_editor.py +681 -0
- dynamic_settings_widget/standalone/info_label.py +190 -0
- dynamic_settings_widget/standalone/int_spin_box.py +627 -0
- dynamic_settings_widget/standalone/multi_choice_editor.py +428 -0
- dynamic_settings_widget/standalone/password_editor.py +348 -0
- dynamic_settings_widget/standalone/path_editor.py +615 -0
- dynamic_settings_widget/standalone/protected_group_box.py +287 -0
- dynamic_settings_widget/standalone/server_connection_editor.py +642 -0
- dynamic_settings_widget/standalone/slider_spin_box.py +840 -0
- dynamic_settings_widget/standalone/sound_selection_widget.py +710 -0
- dynamic_settings_widget/standalone/status_label.py +148 -0
- dynamic_settings_widget/standalone/switch_editor.py +293 -0
- dynamic_settings_widget/standalone/text_editor.py +265 -0
- dynamic_settings_widget/testlab/__init__.py +1 -0
- dynamic_settings_widget/testlab/__main__.py +5 -0
- dynamic_settings_widget/testlab/app.py +699 -0
- dynamic_settings_widget/testlab/assets/extra_sounds/Signal.wav +0 -0
- dynamic_settings_widget/testlab/assets/sounds/Benachrichtigung.wav +0 -0
- dynamic_settings_widget/testlab/assets/sounds/feedback/Signal.wav +0 -0
- dynamic_settings_widget/testlab/definitions/broken_base.json +25 -0
- dynamic_settings_widget/testlab/definitions/demo.json +634 -0
- dynamic_settings_widget/testlab/definitions/gallery.json +255 -0
- dynamic_settings_widget/testlab/definitions/override_example.json +41 -0
- dynamic_settings_widget/testlab/definitions/override_invalid.json +11 -0
- dynamic_settings_widget/testlab/definitions/override_syntax_error.json +5 -0
- dynamic_settings_widget/testlab/definitions/override_weaken.json +10 -0
- dynamic_settings_widget/testlab/definitions/voice_v2/01_left_top.json +1190 -0
- dynamic_settings_widget/testlab/definitions/voice_v2/catalog.json +1930 -0
- dynamic_settings_widget/testlab/definitions/voice_v2/models.json +141 -0
- dynamic_settings_widget/testlab/definitions/voice_v2/wakewords.json +161 -0
- dynamic_settings_widget/testlab/dummy.py +353 -0
- dynamic_settings_widget/testlab/extensions.py +149 -0
- dynamic_settings_widget/testlab/gallery.py +223 -0
- dynamic_settings_widget/testlab/http_adapter.py +430 -0
- dynamic_settings_widget/testlab/http_server.py +493 -0
- dynamic_settings_widget/testlab/voice_v2.py +251 -0
- dynamic_settings_widget/ui/__init__.py +23 -0
- dynamic_settings_widget/ui/base.py +63 -0
- dynamic_settings_widget/ui/builders.py +226 -0
- dynamic_settings_widget/ui/containers.py +441 -0
- dynamic_settings_widget/ui/dialog.py +231 -0
- dynamic_settings_widget/ui/editing.py +51 -0
- dynamic_settings_widget/ui/row.py +810 -0
- dynamic_settings_widget/ui/view.py +248 -0
- dynamic_settings_widget/widgets/__init__.py +74 -0
- dynamic_settings_widget/widgets/base.py +145 -0
- dynamic_settings_widget/widgets/bridge.py +222 -0
- dynamic_settings_widget/widgets/theme.py +107 -0
- dynamic_settings_widget-2.0.0.dist-info/METADATA +237 -0
- dynamic_settings_widget-2.0.0.dist-info/RECORD +90 -0
- dynamic_settings_widget-2.0.0.dist-info/WHEEL +5 -0
- dynamic_settings_widget-2.0.0.dist-info/entry_points.txt +5 -0
- dynamic_settings_widget-2.0.0.dist-info/licenses/LICENSE +21 -0
- dynamic_settings_widget-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2026 marcosudau-vps
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
"""TextEditor – ein- oder mehrzeiliger Text.
|
|
24
|
+
|
|
25
|
+
Autarke Einzeldatei: benötigt nur Python ≥ 3.11 und PySide6 (Essentials). Die Datei
|
|
26
|
+
kann allein in ein anderes Projekt kopiert werden.
|
|
27
|
+
|
|
28
|
+
Beispiel::
|
|
29
|
+
|
|
30
|
+
from text_editor import TextEditor
|
|
31
|
+
|
|
32
|
+
editor = TextEditor(placeholder="Name")
|
|
33
|
+
editor.set_value("Anna") # programmatisch, kein value_edited
|
|
34
|
+
editor.value_edited.connect(print) # nur Benutzereingaben
|
|
35
|
+
editor.configure(optional=True) # leeres Feld = None („nicht gesetzt“)
|
|
36
|
+
|
|
37
|
+
Optionen (``configure``): ``optional``, ``placeholder``.
|
|
38
|
+
Konstruktor: ``multiline`` (mehrzeilig), ``lines`` (sichtbare Zeilen), ``placeholder``.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
from __future__ import annotations
|
|
42
|
+
|
|
43
|
+
from contextlib import contextmanager
|
|
44
|
+
from typing import Any
|
|
45
|
+
|
|
46
|
+
from PySide6.QtCore import Signal
|
|
47
|
+
from PySide6.QtWidgets import QHBoxLayout, QLineEdit, QPlainTextEdit, QWidget
|
|
48
|
+
|
|
49
|
+
__all__ = ["TextEditor"]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# ── Wertbasis ─ identisch in allen Editor-Dateien (bewusst kopiert, Test prüft Gleichheit) ──
|
|
53
|
+
def _same(a: Any, b: Any) -> bool:
|
|
54
|
+
"""Gleichheit ohne Pythons ``True == 1``-Vermischung."""
|
|
55
|
+
if a is b:
|
|
56
|
+
return True
|
|
57
|
+
if isinstance(a, bool) != isinstance(b, bool):
|
|
58
|
+
return False
|
|
59
|
+
if isinstance(a, list) and isinstance(b, list):
|
|
60
|
+
return len(a) == len(b) and all(_same(x, y) for x, y in zip(a, b))
|
|
61
|
+
if isinstance(a, dict) and isinstance(b, dict):
|
|
62
|
+
return a.keys() == b.keys() and all(_same(a[k], b[k]) for k in a)
|
|
63
|
+
try:
|
|
64
|
+
return bool(a == b)
|
|
65
|
+
except Exception: # noqa: BLE001 – fremde Typen ohne Vergleich
|
|
66
|
+
return False
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class _ValueWidget(QWidget):
|
|
70
|
+
"""Gemeinsamer Vertrag aller Editoren.
|
|
71
|
+
|
|
72
|
+
* ``value()`` / ``set_value(v)`` – ``None`` bedeutet „nicht gesetzt“; ein Wert falschen
|
|
73
|
+
Typs löst ``ValueError`` aus und wird nie still umgewandelt.
|
|
74
|
+
* ``value_changed(object)`` – jede Wertänderung, auch programmatisch.
|
|
75
|
+
* ``value_edited(object)`` – nur Änderungen durch den Benutzer.
|
|
76
|
+
* ``configure(**optionen)`` – Schlüssel aus ``OPTIONS``; unbekannte → ``TypeError``.
|
|
77
|
+
* ``set_read_only(bool)``, ``input_error()`` / ``input_error_changed(str)``, ``commit()``.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
value_changed = Signal(object)
|
|
81
|
+
value_edited = Signal(object)
|
|
82
|
+
input_error_changed = Signal(str)
|
|
83
|
+
|
|
84
|
+
#: Schlüssel, die ``configure()`` annimmt.
|
|
85
|
+
OPTIONS: tuple[str, ...] = ("optional",)
|
|
86
|
+
|
|
87
|
+
def __init__(self, parent: QWidget | None = None) -> None:
|
|
88
|
+
super().__init__(parent)
|
|
89
|
+
self._optional = False
|
|
90
|
+
self._read_only = False
|
|
91
|
+
self._silent = 0
|
|
92
|
+
self._last_error = ""
|
|
93
|
+
|
|
94
|
+
# -- von Unterklassen bereitzustellen ------------------------------------------------
|
|
95
|
+
def value(self) -> Any:
|
|
96
|
+
raise NotImplementedError
|
|
97
|
+
|
|
98
|
+
def _apply_value(self, value: Any) -> None:
|
|
99
|
+
raise NotImplementedError
|
|
100
|
+
|
|
101
|
+
def _apply_options(self) -> None:
|
|
102
|
+
"""Darstellung nach ``configure()`` nachführen."""
|
|
103
|
+
|
|
104
|
+
def _apply_read_only(self, read_only: bool) -> None:
|
|
105
|
+
self.setEnabled(not read_only)
|
|
106
|
+
|
|
107
|
+
def input_error(self) -> str:
|
|
108
|
+
"""Grund, warum die aktuelle Eingabe keinen gültigen Wert ergibt (sonst leer)."""
|
|
109
|
+
return ""
|
|
110
|
+
|
|
111
|
+
def commit(self) -> None:
|
|
112
|
+
"""Schließt eine angefangene Eingabe ab."""
|
|
113
|
+
|
|
114
|
+
# -- öffentliche Schnittstelle --------------------------------------------------------
|
|
115
|
+
def set_value(self, value: Any) -> None:
|
|
116
|
+
"""Setzt den Wert programmatisch (ohne ``value_edited``)."""
|
|
117
|
+
old = self.value()
|
|
118
|
+
with self._programmatic():
|
|
119
|
+
self._apply_value(value)
|
|
120
|
+
new = self.value()
|
|
121
|
+
if not _same(old, new):
|
|
122
|
+
self.value_changed.emit(new)
|
|
123
|
+
self._check_error()
|
|
124
|
+
|
|
125
|
+
def configure(self, **options: Any) -> None:
|
|
126
|
+
"""Setzt mehrere Optionen auf einmal, z. B. ``configure(optional=True)``."""
|
|
127
|
+
unknown = sorted(set(options) - set(self.OPTIONS))
|
|
128
|
+
if unknown:
|
|
129
|
+
raise TypeError(f"{type(self).__name__}: unbekannte Option(en) {', '.join(unknown)}")
|
|
130
|
+
for key, value in options.items():
|
|
131
|
+
self._set_option(key, value)
|
|
132
|
+
with self._programmatic():
|
|
133
|
+
self._apply_options()
|
|
134
|
+
self._check_error()
|
|
135
|
+
|
|
136
|
+
def options(self) -> dict[str, Any]:
|
|
137
|
+
"""Aktuelle Optionen."""
|
|
138
|
+
return {key: getattr(self, f"_{key}") for key in self.OPTIONS}
|
|
139
|
+
|
|
140
|
+
def _set_option(self, key: str, value: Any) -> None:
|
|
141
|
+
if key == "optional":
|
|
142
|
+
value = bool(value)
|
|
143
|
+
setattr(self, f"_{key}", value)
|
|
144
|
+
|
|
145
|
+
def set_optional(self, optional: bool) -> None:
|
|
146
|
+
self.configure(optional=optional)
|
|
147
|
+
|
|
148
|
+
def is_optional(self) -> bool:
|
|
149
|
+
return self._optional
|
|
150
|
+
|
|
151
|
+
def set_read_only(self, read_only: bool) -> None:
|
|
152
|
+
self._read_only = bool(read_only)
|
|
153
|
+
self._apply_read_only(self._read_only)
|
|
154
|
+
|
|
155
|
+
def is_read_only(self) -> bool:
|
|
156
|
+
return self._read_only
|
|
157
|
+
|
|
158
|
+
# -- Hilfen für Unterklassen ----------------------------------------------------------
|
|
159
|
+
@contextmanager
|
|
160
|
+
def _programmatic(self):
|
|
161
|
+
self._silent += 1
|
|
162
|
+
try:
|
|
163
|
+
yield
|
|
164
|
+
finally:
|
|
165
|
+
self._silent -= 1
|
|
166
|
+
|
|
167
|
+
def _user_changed(self, *_: Any) -> None:
|
|
168
|
+
"""Nach einer echten Benutzereingabe aufzurufen."""
|
|
169
|
+
if self._silent:
|
|
170
|
+
return
|
|
171
|
+
value = self.value()
|
|
172
|
+
self._check_error()
|
|
173
|
+
self.value_changed.emit(value)
|
|
174
|
+
self.value_edited.emit(value)
|
|
175
|
+
|
|
176
|
+
def _check_error(self) -> None:
|
|
177
|
+
error = self.input_error()
|
|
178
|
+
if error != self._last_error:
|
|
179
|
+
self._last_error = error
|
|
180
|
+
self.input_error_changed.emit(error)
|
|
181
|
+
# ── Ende Wertbasis ──
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class TextEditor(_ValueWidget):
|
|
185
|
+
"""Ein- oder mehrzeiliger Text. Bei ``optional`` bedeutet ein leeres Feld „nicht gesetzt“ (``None``)."""
|
|
186
|
+
|
|
187
|
+
OPTIONS = ("optional", "placeholder")
|
|
188
|
+
|
|
189
|
+
def __init__(
|
|
190
|
+
self, parent: QWidget | None = None, *, multiline: bool = False, lines: int = 4, placeholder: str = ""
|
|
191
|
+
) -> None:
|
|
192
|
+
super().__init__(parent)
|
|
193
|
+
self._null = False
|
|
194
|
+
self._placeholder = placeholder
|
|
195
|
+
layout = QHBoxLayout(self)
|
|
196
|
+
layout.setContentsMargins(0, 0, 0, 0)
|
|
197
|
+
self._edit: QLineEdit | QPlainTextEdit
|
|
198
|
+
if multiline:
|
|
199
|
+
edit = QPlainTextEdit(self)
|
|
200
|
+
edit.setTabChangesFocus(True)
|
|
201
|
+
edit.setFixedHeight(edit.fontMetrics().lineSpacing() * max(2, lines) + 14)
|
|
202
|
+
edit.textChanged.connect(self._on_text)
|
|
203
|
+
self._edit = edit
|
|
204
|
+
else:
|
|
205
|
+
line = QLineEdit(self)
|
|
206
|
+
line.textEdited.connect(self._on_text)
|
|
207
|
+
self._edit = line
|
|
208
|
+
self._edit.setMinimumWidth(80)
|
|
209
|
+
layout.addWidget(self._edit)
|
|
210
|
+
self.setFocusProxy(self._edit)
|
|
211
|
+
self._apply_options()
|
|
212
|
+
|
|
213
|
+
@property
|
|
214
|
+
def line_edit(self) -> QLineEdit | QPlainTextEdit:
|
|
215
|
+
"""Das eigentliche Eingabefeld (``QLineEdit`` bzw. ``QPlainTextEdit``)."""
|
|
216
|
+
return self._edit
|
|
217
|
+
|
|
218
|
+
def text(self) -> str:
|
|
219
|
+
return self._edit.text() if isinstance(self._edit, QLineEdit) else self._edit.toPlainText()
|
|
220
|
+
|
|
221
|
+
def _on_text(self, *_: Any) -> None:
|
|
222
|
+
if not self._silent:
|
|
223
|
+
self._null = False
|
|
224
|
+
self._user_changed()
|
|
225
|
+
|
|
226
|
+
def value(self) -> str | None:
|
|
227
|
+
text = self.text()
|
|
228
|
+
if not text and (self._null or self._optional):
|
|
229
|
+
return None
|
|
230
|
+
return text
|
|
231
|
+
|
|
232
|
+
def _apply_value(self, value: Any) -> None:
|
|
233
|
+
if value is not None and not isinstance(value, str):
|
|
234
|
+
raise ValueError("Text erwartet")
|
|
235
|
+
self._null = value is None
|
|
236
|
+
text = value or ""
|
|
237
|
+
if self.text() != text:
|
|
238
|
+
if isinstance(self._edit, QLineEdit):
|
|
239
|
+
self._edit.setText(text)
|
|
240
|
+
else:
|
|
241
|
+
self._edit.setPlainText(text)
|
|
242
|
+
|
|
243
|
+
def _apply_options(self) -> None:
|
|
244
|
+
self._edit.setPlaceholderText(self._placeholder)
|
|
245
|
+
|
|
246
|
+
def _apply_read_only(self, read_only: bool) -> None:
|
|
247
|
+
self._edit.setReadOnly(read_only)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _demo() -> None: # pragma: no cover – python text_editor.py
|
|
251
|
+
from PySide6.QtWidgets import QApplication, QVBoxLayout
|
|
252
|
+
|
|
253
|
+
app = QApplication.instance() or QApplication([])
|
|
254
|
+
host = QWidget()
|
|
255
|
+
layout = QVBoxLayout(host)
|
|
256
|
+
single, multi = TextEditor(placeholder="Einzeilig"), TextEditor(multiline=True, lines=3)
|
|
257
|
+
for editor in (single, multi):
|
|
258
|
+
editor.value_edited.connect(lambda v: print("Benutzer:", repr(v)))
|
|
259
|
+
layout.addWidget(editor)
|
|
260
|
+
host.show()
|
|
261
|
+
app.exec()
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
if __name__ == "__main__":
|
|
265
|
+
_demo()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""TestLab: eigenständige Testanwendung mit Dummy- und HTTP-Anbindung."""
|