pythonqtside 1.1.12__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.
Files changed (42) hide show
  1. pythonqtside/Qt.py +14 -0
  2. pythonqtside/QtCore.py +14 -0
  3. pythonqtside/QtGui.py +14 -0
  4. pythonqtside/QtNetwork.py +14 -0
  5. pythonqtside/QtOpenGL.py +14 -0
  6. pythonqtside/QtSvg.py +14 -0
  7. pythonqtside/QtUiTools.py +14 -0
  8. pythonqtside/QtWidgets.py +14 -0
  9. pythonqtside/QtXmlPatterns.py +14 -0
  10. pythonqtside/__init__.py +34 -0
  11. pythonqtside/_app.py +319 -0
  12. pythonqtside/_app_cleanup.py +216 -0
  13. pythonqtside/_app_conversions.py +106 -0
  14. pythonqtside/_app_dialogs.py +74 -0
  15. pythonqtside/_app_flags.py +79 -0
  16. pythonqtside/_app_imports.py +146 -0
  17. pythonqtside/_app_keywords.py +210 -0
  18. pythonqtside/_app_native.py +404 -0
  19. pythonqtside/_app_proxy.py +43 -0
  20. pythonqtside/_app_source.py +110 -0
  21. pythonqtside/_differences.json +9808 -0
  22. pythonqtside/_flags.json +210 -0
  23. pythonqtside/_implicit_conversions.json +1975 -0
  24. pythonqtside/_inventory.json +115478 -0
  25. pythonqtside/_keywords.json +1 -0
  26. pythonqtside/_out_parameters.json +465 -0
  27. pythonqtside/_qtwidgets.json +202 -0
  28. pythonqtside/_routing.py +95 -0
  29. pythonqtside/compat.py +44 -0
  30. pythonqtside/tooling/__init__.py +2 -0
  31. pythonqtside/tooling/conversions.py +433 -0
  32. pythonqtside/tooling/differences.py +290 -0
  33. pythonqtside/tooling/flags.py +156 -0
  34. pythonqtside/tooling/inventory.py +149 -0
  35. pythonqtside/tooling/join.py +184 -0
  36. pythonqtside/tooling/keywords.py +259 -0
  37. pythonqtside/tooling/surface.py +191 -0
  38. pythonqtside-1.1.12.dist-info/METADATA +468 -0
  39. pythonqtside-1.1.12.dist-info/RECORD +42 -0
  40. pythonqtside-1.1.12.dist-info/WHEEL +4 -0
  41. pythonqtside-1.1.12.dist-info/licenses/LICENSE +201 -0
  42. pythonqtside-1.1.12.dist-info/licenses/NOTICE +7 -0
pythonqtside/Qt.py ADDED
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/Qt.py
2
+ """Qt objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('Qt', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('Qt')
pythonqtside/QtCore.py ADDED
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtCore.py
2
+ """QtCore objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtCore', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtCore')
pythonqtside/QtGui.py ADDED
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtGui.py
2
+ """QtGui objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtGui', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtGui')
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtNetwork.py
2
+ """QtNetwork objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtNetwork', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtNetwork')
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtOpenGL.py
2
+ """QtOpenGL objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtOpenGL', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtOpenGL')
pythonqtside/QtSvg.py ADDED
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtSvg.py
2
+ """QtSvg objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtSvg', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtSvg')
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtUiTools.py
2
+ """QtUiTools objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtUiTools', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtUiTools')
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtWidgets.py
2
+ """QtWidgets objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtWidgets', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtWidgets')
@@ -0,0 +1,14 @@
1
+ # this_file: src/pythonqtside/QtXmlPatterns.py
2
+ """QtXmlPatterns objects routed from FontLab's native PythonQt through Echopy."""
3
+ from typing import Any
4
+ from ._routing import member, names
5
+
6
+
7
+ def __getattr__(name: str) -> Any:
8
+ if name.startswith("_"):
9
+ raise AttributeError(name)
10
+ return member('QtXmlPatterns', name)
11
+
12
+
13
+ def __dir__() -> list[str]:
14
+ return names('QtXmlPatterns')
@@ -0,0 +1,34 @@
1
+ # this_file: src/pythonqtside/__init__.py
2
+ """Native Qt5 namespace routing; measured compatibility work is planned separately."""
3
+
4
+ from importlib import import_module
5
+ from types import ModuleType
6
+
7
+ from ._app import AppHandle, run_app
8
+
9
+ __all__ = [
10
+ "AppHandle",
11
+ "Qt",
12
+ "QtCore",
13
+ "QtGui",
14
+ "QtNetwork",
15
+ "QtOpenGL",
16
+ "QtSvg",
17
+ "QtUiTools",
18
+ "QtWidgets",
19
+ "QtXmlPatterns",
20
+ "compat",
21
+ "run_app",
22
+ ]
23
+
24
+
25
+ def __getattr__(name: str) -> ModuleType:
26
+ if name not in __all__:
27
+ raise AttributeError(name)
28
+ module = import_module(__name__ + "." + name)
29
+ globals()[name] = module
30
+ return module
31
+
32
+
33
+ def __dir__() -> list[str]:
34
+ return sorted(set(globals()) | set(__all__))
pythonqtside/_app.py ADDED
@@ -0,0 +1,319 @@
1
+ # this_file: src/pythonqtside/_app.py
2
+ """Retained unchanged-source applications scoped to FontLab's existing Qt host."""
3
+
4
+ import gc
5
+ import re
6
+ from functools import partial
7
+ from pathlib import Path
8
+ from types import MappingProxyType
9
+ from typing import Any
10
+
11
+ from . import _app_flags, _app_keywords, _app_native
12
+ from ._app_cleanup import cleanup, connection_call, disconnect_connections
13
+ from ._app_imports import ImportContext, freeze
14
+ from ._app_proxy import ApplicationProxy
15
+
16
+ _ACTIVE_HANDLES = set()
17
+
18
+
19
+ def _closed(*args: Any, **kwargs: Any) -> Any:
20
+ raise RuntimeError("The embedded application handle is closed")
21
+
22
+
23
+ class AppHandle:
24
+ """Own constructor-created Qt objects and retain source/import globals until close."""
25
+
26
+ def __init__(
27
+ self,
28
+ path: Path,
29
+ parent: Any,
30
+ application: Any,
31
+ application_classes: tuple[type, ...],
32
+ ) -> None:
33
+ self.closed = False
34
+ self.cleanup_errors = ()
35
+ self._objects = []
36
+ self._connections = []
37
+ self._parent = parent
38
+ self._application_classes = application_classes
39
+ self._application = ApplicationProxy(self, application)
40
+ self._namespace = {"__name__": "__main__", "__package__": ""}
41
+ self._context = ImportContext(self, path.parent)
42
+ self._executing = False
43
+ self._constructing = 0
44
+
45
+ @property
46
+ def namespace(self) -> MappingProxyType:
47
+ return (
48
+ MappingProxyType(self._namespace)
49
+ if not self.closed
50
+ else MappingProxyType({})
51
+ )
52
+
53
+ @property
54
+ def reports(self) -> MappingProxyType:
55
+ return MappingProxyType(dict(self._context.reports))
56
+
57
+ @property
58
+ def identity_report(self) -> MappingProxyType:
59
+ return freeze(
60
+ {
61
+ "routed_classes": dict(self._context.identities),
62
+ "application_proxy": type(self._application),
63
+ "native_application_classes": self._application_classes,
64
+ "limits": (
65
+ "QObject recognition uses native ancestry plus metaObject/parent/deleteLater capabilities.",
66
+ "Only constructor results are owned; arbitrary API return values are borrowed.",
67
+ "Dynamic exec/eval source, importlib imports, namespace packages and application subclasses/settings are unsupported.",
68
+ ),
69
+ }
70
+ )
71
+
72
+ def _require_open(self) -> None:
73
+ _app_native.require_host_thread()
74
+ if self.closed:
75
+ raise RuntimeError("The embedded application handle is closed")
76
+
77
+ def _own(self, value: Any) -> Any:
78
+ if _app_native.qobject_instance(value) and not any(
79
+ value is obj for obj in self._objects
80
+ ):
81
+ self._objects.append(value)
82
+ return value
83
+
84
+ def _prepare(self, callee: Any, keywords: bool = False) -> Any:
85
+ signal_method = _app_native.native_signal_method(callee)
86
+ if signal_method is not None:
87
+ self._require_open()
88
+ receiver, name = signal_method
89
+ owner, signal_name = self._signal_owner(receiver)
90
+ return connection_call(
91
+ receiver, name, callee, self._connections, owner, signal_name
92
+ )
93
+ callee = _app_native.captured_call(callee, keywords)
94
+ if any(callee is kind for kind in (bytes, bytearray, memoryview)):
95
+ return partial(_app_native.byte_call, callee)
96
+ # Ordinary Python callables, including aliased frame builtins, run directly.
97
+ if not _app_native.native_class(callee):
98
+ return callee
99
+ if any(base in self._application_classes for base in callee.__mro__):
100
+ raise NotImplementedError("Embedded application subclasses are unsupported")
101
+
102
+ keywords = _app_keywords.native_init(callee)
103
+
104
+ def construct(*args: Any, **kwargs: Any) -> Any:
105
+ self._require_open()
106
+ self._constructing += 1
107
+ try:
108
+ if kwargs and keywords:
109
+ return _app_keywords.construct(
110
+ callee, args, kwargs, self._connect, self._own
111
+ )
112
+ if keywords: # measured QFlags positions (_flags.json)
113
+ native = _app_keywords.native_base(callee)
114
+ args = _app_flags.convert(native, "__init__", args)
115
+ return self._own(callee(*args, **kwargs))
116
+ finally:
117
+ self._constructing -= 1
118
+
119
+ return construct
120
+
121
+ def _connect(
122
+ self, signal: Any, slot: Any, owner: Any = None, name: str | None = None
123
+ ) -> Any:
124
+ """Constructor signal keywords connect through the tracked path."""
125
+ return connection_call(
126
+ signal, "connect", signal.connect, self._connections, owner, name
127
+ )(slot)
128
+
129
+ def _signal_owner(self, signal: Any) -> tuple[Any, str | None]:
130
+ """The QObject and signal name behind an aliased or captured signal.
131
+
132
+ Measured (pqs-g04/review2/probe_signal_owner.json): a PythonQt signal
133
+ wrapper's only GC referent is its owner, and its repr
134
+ (``<qt signal finished of QProcess instance at 0x...>``) carries the
135
+ signal name and ``id(owner)``. Works for owned and borrowed senders."""
136
+ if not _app_native.native_signal_instance(signal):
137
+ return None, None
138
+ match = re.match(
139
+ r"<qt signal (\w+) of \w+ instance at (0x[0-9a-fA-F]+)", repr(signal)
140
+ )
141
+ if match is None:
142
+ return None, None
143
+ name, address = match.group(1), int(match.group(2), 16)
144
+ for owner in gc.get_referents(signal):
145
+ if id(owner) != address or not _app_native.native_instance(owner):
146
+ continue
147
+ try:
148
+ candidate = getattr(owner, name)
149
+ except Exception: # noqa: BLE001, S112 - destroyed wrappers raise
150
+ continue
151
+ if _app_native.same_connection_receiver(candidate, signal):
152
+ return owner, name
153
+ return None, None
154
+
155
+ def _super_init(self, receiver: super, value: Any) -> Any:
156
+ """``super().__init__(parent=p)`` reaching a native constructor."""
157
+ native = None
158
+ for base in _app_native._super_bases(receiver):
159
+ if base.__module__.startswith("PythonQt"):
160
+ native = base
161
+ break
162
+ if "__init__" in vars(base):
163
+ return value
164
+ if native is None:
165
+ return value
166
+ instance = receiver.__self__
167
+
168
+ def initialize(*args: Any, **kwargs: Any) -> Any:
169
+ if not kwargs:
170
+ return value(*_app_flags.convert(native, "__init__", args))
171
+ return _app_keywords.initialize(
172
+ value, instance, native, args, kwargs, self._connect
173
+ )
174
+
175
+ return initialize
176
+
177
+ def _resolve(
178
+ self,
179
+ receiver: Any,
180
+ name: str,
181
+ keywords: bool = False,
182
+ member: str | None = None,
183
+ ) -> Any:
184
+ self._require_open()
185
+ if member is not None: # `receiver.name.member(...)`, member is (dis)connect
186
+ signal = getattr(receiver, name)
187
+ if _app_native.native_signal_instance(
188
+ signal
189
+ ) and _app_native.native_instance(receiver):
190
+ method = getattr(signal, member)
191
+ return connection_call(
192
+ signal, member, method, self._connections, receiver, name
193
+ )
194
+ return self._resolve(signal, member, keywords)
195
+ value = _app_native.resolve(receiver, name, keywords)
196
+ if name == "__init__" and isinstance(receiver, super):
197
+ value = self._super_init(receiver, value)
198
+ instance = receiver.__self__ if isinstance(receiver, super) else receiver
199
+ if (
200
+ self._constructing
201
+ and name == "__init__"
202
+ and _app_native.native_instance(instance)
203
+ ):
204
+ self._own(instance)
205
+ if name == "__init__" and _app_native.native_class(receiver):
206
+ native_init = _app_keywords.native_init(receiver)
207
+
208
+ def initialize(instance: Any, *args: Any, **kwargs: Any) -> Any:
209
+ if self._constructing:
210
+ self._own(instance)
211
+ if kwargs and native_init:
212
+ return _app_keywords.initialize(
213
+ lambda *a: value(instance, *a),
214
+ instance,
215
+ _app_keywords.native_base(receiver),
216
+ args,
217
+ kwargs,
218
+ self._connect,
219
+ )
220
+ if native_init:
221
+ native = _app_keywords.native_base(receiver)
222
+ args = _app_flags.convert(native, "__init__", args)
223
+ return value(instance, *args, **kwargs)
224
+
225
+ return initialize
226
+ if (
227
+ name in {"connect", "disconnect"}
228
+ and (
229
+ _app_native.native_instance(receiver)
230
+ or _app_native.native_signal_instance(receiver)
231
+ )
232
+ and callable(value)
233
+ ):
234
+ owner, signal_name = self._signal_owner(receiver)
235
+ return connection_call(
236
+ receiver, name, value, self._connections, owner, signal_name
237
+ )
238
+ if name == "load" and _app_native.ui_loader(receiver):
239
+ # Qt: the caller owns the widget QUiLoader.load() creates.
240
+ return lambda *args, **kwargs: self._own(value(*args, **kwargs))
241
+ if name == "show" and any(receiver is obj for obj in self._objects):
242
+
243
+ def show(*args: Any, **kwargs: Any) -> Any:
244
+ self._parent_windows()
245
+ return value(*args, **kwargs)
246
+
247
+ return show
248
+ return value
249
+
250
+ def _parent_windows(self) -> None:
251
+ if self._parent is not None:
252
+ for obj in self._objects:
253
+ if _app_native.widget_instance(obj) and obj.parent() is None:
254
+ obj.setParent(self._parent)
255
+
256
+ def close(self) -> None:
257
+ """Disconnect, stop owned work and delete owned graph roots once; retain reports."""
258
+ if self.closed:
259
+ return
260
+ _app_native.require_host_thread()
261
+ self.closed = True
262
+ self.cleanup_errors, retained = cleanup(self._objects, self._connections)
263
+ self._connections.clear()
264
+ self._objects[:] = retained
265
+ if not retained:
266
+ _ACTIVE_HANDLES.discard(self)
267
+ self._context.modules.clear()
268
+ if not self._executing:
269
+ self._clear_namespace()
270
+
271
+ def _clear_namespace(self) -> None:
272
+ """Drop the app's globals, keeping its adapter names so code that still
273
+ runs after close (a Python object the host kept) fails clearly."""
274
+ self._namespace.clear()
275
+ for name in (self._context.call_name, self._context.resolve_name):
276
+ self._namespace[name] = _closed
277
+
278
+ def _disconnect_callbacks(self) -> tuple[str, ...]:
279
+ """Acceptance probe: disconnect while widgets are live, using close's same phase."""
280
+ self._require_open()
281
+ errors = disconnect_connections(self._connections)
282
+ self._connections.clear()
283
+ return errors
284
+
285
+
286
+ def run_app(path: str | Path, *, parent: Any = None) -> AppHandle:
287
+ """Run one original PySide2 source graph without changing the host's import state."""
288
+ application, classes = _app_native.host_application()
289
+ if parent is not None and not _app_native.widget_instance(parent):
290
+ raise TypeError("run_app parent must be a native QWidget")
291
+ path = Path(path).resolve(strict=True)
292
+ handle = AppHandle(path, parent, application, classes)
293
+ _ACTIVE_HANDLES.add(handle)
294
+ handle._executing = True
295
+ try:
296
+ try:
297
+ handle._context.execute(path, handle._namespace)
298
+ except SystemExit as error:
299
+ origin = error.__traceback__
300
+ while origin.tb_next is not None:
301
+ origin = origin.tb_next
302
+ if (
303
+ error.code is not None and error.code != 0
304
+ ) or origin.tb_frame.f_code.co_filename != str(path):
305
+ raise
306
+ if not handle.closed:
307
+ handle._parent_windows()
308
+ except BaseException as error:
309
+ handle.close()
310
+ if handle.cleanup_errors:
311
+ error.add_note(
312
+ "Embedded app cleanup errors: " + "; ".join(handle.cleanup_errors)
313
+ )
314
+ raise
315
+ finally:
316
+ handle._executing = False
317
+ if handle.closed:
318
+ handle._clear_namespace()
319
+ return handle