Skip to content

Instantly share code, notes, and snippets.

@cmaureir
Created February 23, 2022 14:30
Show Gist options
  • Save cmaureir/07ea5e1a32c8e21ff6f50e7a4e64c69b to your computer and use it in GitHub Desktop.
Save cmaureir/07ea5e1a32c8e21ff6f50e7a4e64c69b to your computer and use it in GitHub Desktop.
modules = [
"QtCore",
"QtGui",
"QtWidgets",
"QtHelp",
"QtNetwork",
"QtXml",
"QtOpenGL",
"QtOpenGLWidgets",
"QtPrintSupport",
"QtQml",
"QtQuick",
"QtQuickControls2",
"QtQuickWidgets",
"QtScxml",
"QtSql",
"QtStateMachine",
"QtSvg",
"QtSvgWidgets",
"QtTest",
"QtUiTools",
"Qt3DAnimation",
"Qt3DCore",
"Qt3DExtras",
"Qt3DInput",
"Qt3DLogic",
"Qt3DRender",
"QtConcurrent",
"QtDesigner",
"QtCharts",
"QtDataVisualization",
]
print("h2. Modules not available in PyQt or PySide\n")
not_available = []
for module in modules:
try:
found_pyside = False
found_pyqt = False
if "3D" in module:
exec(f"from PySide6.{module} import {module} as pyside_{module.lower()}")
else:
exec(f"import PySide6.{module} as pyside_{module.lower()}")
found_pyside = True
exec(f"import PyQt6.{module} as pyqt_{module.lower()}")
found_pyqt = True
except ModuleNotFoundError:
if not found_pyside:
print(f"Warning: module *{module}* not found in PySide")
elif not found_pyqt:
print(f"Warning: module *{module}* not found in PyQt")
not_available.append(module)
modules = [i for i in modules if i not in not_available]
same = []
alternatives = {
"pyqtBoundSignal": "SignalInstance",
"pyqtProperty": "Property",
"pyqtSignal": "Signal",
"pyqtEnum": "QEnum",
"pyqtClassInfo": "ClassInfo",
"pyqtSlot": "Slot",
}
print("\nh2. Pending members of modules\n")
for module in modules:
members_pyside = set(dir(eval(f"pyside_{module.lower()}")))
members_pyqt = set(dir(eval(f"pyqt_{module.lower()}")))
difference = [i for i in (members_pyqt - members_pyside) if "__" not in i and "VERSION" not in i]
if difference:
print(f"\n*{module}*: In PyQt but not on PySide")
for i in difference:
if i in alternatives:
print(f"* -{i}- (we have it as {alternatives[i]})")
else:
print(f"* {i}")
else:
same.append(module)
print("\nh2. Modules that offer the same\n")
for module in same:
print(f"\n*{module}*: PyQt and PySide have the same.", end="")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment