1+ # -*- coding: utf-8 -*-
2+ """
3+ Qt Compatibility Layer
4+
5+ This module provides a unified interface for PyQt6 and PySide6,
6+ allowing the application to work on macOS where Nuitka only supports PySide6.
7+
8+ Usage:
9+ from core.qt_compat import QtWidgets, QtCore, QtGui, Signal
10+
11+ On Windows/Linux: Uses PyQt6
12+ On macOS: Uses PySide6 (for Nuitka compatibility)
13+ """
14+
15+ import sys
16+ import os
17+
18+ # Force PySide6 on macOS for Nuitka compatibility
19+ # Can be overridden with environment variable QT_BINDING
20+ FORCE_PYSIDE6 = sys .platform == "darwin"
21+ QT_BINDING = os .environ .get ("QT_BINDING" , "auto" )
22+
23+ if QT_BINDING == "pyside6" or (QT_BINDING == "auto" and FORCE_PYSIDE6 ):
24+ # Use PySide6
25+ from PySide6 .QtWidgets import *
26+ from PySide6 .QtCore import *
27+ from PySide6 .QtGui import *
28+
29+ # PySide6 uses Signal instead of pyqtSignal
30+ Signal = Signal
31+ Slot = Slot
32+ Property = Property
33+
34+ QT_BINDING_NAME = "PySide6"
35+ else :
36+ # Use PyQt6 (default for Windows/Linux)
37+ from PyQt6 .QtWidgets import *
38+ from PyQt6 .QtCore import *
39+ from PyQt6 .QtGui import *
40+
41+ # PyQt6 uses pyqtSignal, map to Signal for compatibility
42+ Signal = pyqtSignal
43+ Slot = pyqtSlot
44+ Property = pyqtProperty
45+
46+ QT_BINDING_NAME = "PyQt6"
47+
48+ # Export common classes that might be imported directly
49+ __all__ = [
50+ # QtWidgets
51+ "QApplication" , "QWidget" , "QMainWindow" , "QDialog" , "QMessageBox" ,
52+ "QVBoxLayout" , "QHBoxLayout" , "QGridLayout" , "QScrollArea" ,
53+ "QPushButton" , "QLabel" , "QLineEdit" , "QTextEdit" , "QComboBox" ,
54+ "QCheckBox" , "QTreeWidget" , "QTreeWidgetItem" , "QTabWidget" ,
55+ "QFileDialog" , "QMenu" , "QMenuBar" , "QToolBar" , "QStatusBar" ,
56+ "QSplitter" , "QGroupBox" , "QSpinBox" , "QDoubleSpinBox" ,
57+ "QSlider" , "QProgressBar" , "QListWidget" , "QTableWidget" ,
58+ "QAction" , "QActionGroup" , "QSizePolicy" ,
59+
60+ # QtCore
61+ "Qt" , "QObject" , "QSize" , "QPoint" , "QRect" , "QSettings" ,
62+ "QTimer" , "QEvent" , "QMimeData" , "QRegularExpression" ,
63+ "Signal" , "Slot" , "Property" ,
64+
65+ # QtGui
66+ "QPainter" , "QPen" , "QBrush" , "QColor" , "QFont" , "QPixmap" ,
67+ "QIcon" , "QImage" , "QDrag" , "QCursor" , "QKeySequence" ,
68+ "QSyntaxHighlighter" , "QTextCharFormat" ,
69+ "QMouseEvent" , "QWheelEvent" , "QDragEnterEvent" , "QDropEvent" ,
70+
71+ # Module info
72+ "QT_BINDING_NAME" ,
73+ ]
0 commit comments