Skip to content

Commit eea0642

Browse files
committed
WIP: remove the windows only QtAxContainer module
1 parent 2ba79bf commit eea0642

File tree

4 files changed

+63
-27
lines changed

4 files changed

+63
-27
lines changed

CAVEATS.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,18 +437,47 @@ unable to automatically fix your code but shows you possible code that you will
437437
need to manually fix.
438438

439439

440-
#### QtCore.QWinEventNotifier
440+
#### Platform specific members
441441

442-
This class is only available on Windows, for now we are not exposing it in Qt.py.
442+
There are several platform specific Qt members that could be exposed by Qt.py.
443+
Qt.py is targeted at exposing members common across all supported Qt versions
444+
and platforms, so we are not including them by default.
445+
446+
- `QtCore.QWinEventNotifier`
447+
- `QtAxContainer.QAxBase` Available as `QAxContainer` in PyQt5/6.
448+
- `QtAxContainer.QAxObject` Available as `QAxContainer` in PyQt5/6.
449+
- `QtAxContainer.QAxWidget` Available as `QAxContainer` in PyQt5/6.
443450

444451

445452
##### Workaround
446453

447-
This can be added to Qt.py using QtSiteConfig.
454+
They can be added to Qt.py using QtSiteConfig.
448455

449456

450457
```python
458+
import sys
459+
460+
451461
def update_members(members):
452-
# Add the windows only `QWinEventNotifier`
453-
members["QtCore"].append("QsciAPIs")
462+
# Add windows only `QWinEventNotifier` class
463+
if sys.platform == "win32":
464+
members["QtCore"].append("QWinEventNotifier")
465+
466+
# Add the windows only QtAxContainer class
467+
members["QtAxContainer"] = [
468+
"QAxBase"
469+
"QAxObject"
470+
"QAxWidget"
471+
]
472+
473+
def update_misplaced_members(members):
474+
if sys.platform != "win32":
475+
return
476+
477+
# Correctly map the Windows only QtAxContainer misplaced in PyQtX.
478+
for binding in ("PyQt6", "PyQt5"):
479+
members[binding].setdefault("__misplaced__", []).append("QAxContainer")
480+
members[binding]["QAxContainer.QAxBase"] = "QtAxContainer.QAxBase"
481+
members[binding]["QAxContainer.QAxObject"] = "QtAxContainer.QAxObject"
482+
members[binding]["QAxContainer.QAxWidget"] = "QtAxContainer.QAxWidget"
454483
```

membership.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
SKIP_MODULES = [
1414
'PyQt5.Qt', # This module only exists in PyQt5 and is not exposed by Qt.py
1515
'PyQt5.uic.pyuic', # Problematic as it is executed on import
16-
'QtCore.QWinEventNotifier', # This class is only available on Windows.
16+
# These modules are only available on windows
17+
"PyQt5.QAxContainer",
18+
"PyQt6.QAxContainer",
19+
"PySide2.QtAxContainer",
20+
"PySide6.QtAxContainer",
1721
]
1822
SKIP_MEMBERS = [
19-
'qApp', # See main README.md on qApp
2023
"QIntList", # Missing from Qt5 or PyQt6, but present in ~50 modules
24+
'qApp', # See main README.md on qApp
25+
'QWinEventNotifier', # This class is only available on Windows.
2126
]
2227

2328
# Will contain all modules for the current binding
@@ -33,7 +38,7 @@
3338
# Include these module names in common modules even if they have no common
3439
# members. They will be assigned using the misplaced members.
3540
MISPLACED_MODULES = [
36-
"QtAxContainer",
41+
# "QtAxContainer",
3742
"QtOpenGL",
3843
]
3944

@@ -151,7 +156,7 @@ def compare(dicts):
151156
def membership_table(binding_maps):
152157
rows = {}
153158
headers = (
154-
["Module", "Class"] + list(binding_maps.keys()) + ["Potentially Misplaced"]
159+
["Module", "Class"] + sorted(binding_maps.keys()) + ["Potentially Misplaced"]
155160
)
156161
columns = len(binding_maps) + 1
157162
cls_modules = {}

src/Qt.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"""
8585

8686
_common_members = {
87-
"QtAxContainer": [],
87+
# "QtAxContainer": [],
8888
"QtCore": [
8989
"QAbstractAnimation",
9090
"QAbstractEventDispatcher",
@@ -1406,9 +1406,9 @@ def wrapper(self, descrip):
14061406
"""
14071407
_misplaced_members = {
14081408
"PySide6": {
1409-
"QtAxContainer.QAxBase": "QtAxContainer.QAxBase",
1410-
"QtAxContainer.QAxObject": "QtAxContainer.QAxObject",
1411-
"QtAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
1409+
# "QtAxContainer.QAxBase": "QtAxContainer.QAxBase",
1410+
# "QtAxContainer.QAxObject": "QtAxContainer.QAxObject",
1411+
# "QtAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
14121412
"QtCore.Property": "QtCore.Property",
14131413
"QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel",
14141414
"QtCore.QCoreApplication.translate": ["QtCompat.translate", _translate],
@@ -1449,10 +1449,10 @@ def wrapper(self, descrip):
14491449
"shiboken6.wrapInstance": ["QtCompat.wrapInstance", _wrapinstance],
14501450
},
14511451
"PyQt6": {
1452-
"__misplaced__": ["QAxContainer"],
1453-
"QAxContainer.QAxBase": "QtAxContainer.QAxBase",
1454-
"QAxContainer.QAxObject": "QtAxContainer.QAxObject",
1455-
"QAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
1452+
# "__misplaced__": ["QAxContainer"],
1453+
# "QAxContainer.QAxBase": "QtAxContainer.QAxBase",
1454+
# "QAxContainer.QAxObject": "QtAxContainer.QAxObject",
1455+
# "QAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
14561456
"QtCore.pyqtProperty": "QtCore.Property",
14571457
"QtCore.pyqtSignal": "QtCore.Signal",
14581458
"QtCore.pyqtSlot": "QtCore.Slot",
@@ -1494,9 +1494,9 @@ def wrapper(self, descrip):
14941494
},
14951495
"PySide2": {
14961496
"__misplaced__": ["QtOpenGLFunctions"],
1497-
"QtAxContainer.QAxBase": "QtAxContainer.QAxBase",
1498-
"QtAxContainer.QAxObject": "QtAxContainer.QAxObject",
1499-
"QtAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
1497+
# "QtAxContainer.QAxBase": "QtAxContainer.QAxBase",
1498+
# "QtAxContainer.QAxObject": "QtAxContainer.QAxObject",
1499+
# "QtAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
15001500
"QtCore.Property": "QtCore.Property",
15011501
"QtCore.QAbstractProxyModel": "QtCore.QAbstractProxyModel",
15021502
"QtCore.QCoreApplication.translate": ["QtCompat.translate", _translate],
@@ -1540,14 +1540,14 @@ def wrapper(self, descrip):
15401540
"_QOpenGLFunctions_2_0",
15411541
"_QOpenGLFunctions_2_1",
15421542
"_QOpenGLFunctions_4_1_Core",
1543-
"QAxContainer",
1543+
# "QAxContainer",
15441544
],
15451545
"_QOpenGLFunctions_2_0.QOpenGLFunctions_2_0": "QtOpenGL.QOpenGLFunctions_2_0",
15461546
"_QOpenGLFunctions_2_1.QOpenGLFunctions_2_1": "QtOpenGL.QOpenGLFunctions_2_1",
15471547
"_QOpenGLFunctions_4_1_Core.QOpenGLFunctions_4_1_Core": "QtOpenGL.QOpenGLFunctions_4_1_Core",
1548-
"QAxContainer.QAxBase": "QtAxContainer.QAxBase",
1549-
"QAxContainer.QAxObject": "QtAxContainer.QAxObject",
1550-
"QAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
1548+
# "QAxContainer.QAxBase": "QtAxContainer.QAxBase",
1549+
# "QAxContainer.QAxObject": "QtAxContainer.QAxObject",
1550+
# "QAxContainer.QAxWidget": "QtAxContainer.QAxWidget",
15511551
"QtCore.pyqtProperty": "QtCore.Property",
15521552
"QtCore.pyqtSignal": "QtCore.Signal",
15531553
"QtCore.pyqtSlot": "QtCore.Slot",

tests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,9 @@ def test__misplaced__():
12321232
"""
12331233
import Qt
12341234

1235-
assert Qt.QtAxContainer.QAxBase
1236-
assert Qt.QtAxContainer.QAxWidget
1235+
# NOTE: Windows only
1236+
# assert Qt.QtAxContainer.QAxBase
1237+
# assert Qt.QtAxContainer.QAxWidget
12371238
assert Qt.QtOpenGL.QAbstractOpenGLFunctions
12381239
assert Qt.QtOpenGL.QOpenGLBuffer
12391240
assert Qt.QtOpenGL.QOpenGLFunctions_2_0
@@ -1248,7 +1249,8 @@ def test__misplaced__none():
12481249
os.environ["QT_PREFERRED_BINDING"] = "None"
12491250
import Qt
12501251

1251-
assert Qt.QtAxContainer
1252+
# NOTE: Windows only
1253+
# assert Qt.QtAxContainer
12521254
assert Qt.QtOpenGL
12531255
finally:
12541256
os.environ["QT_PREFERRED_BINDING"] = current

0 commit comments

Comments
 (0)