|
13 | 13 | the ``PyQt5.QtGui`` module. |
14 | 14 | """ |
15 | 15 |
|
16 | | -from . import PYQT5, PYQT4, PYSIDE, PythonQtError |
| 16 | +from . import PYQT5, PYQT4, PYSIDE, PYSIDE2, PythonQtError |
17 | 17 |
|
18 | 18 |
|
19 | 19 | if PYQT5: |
20 | 20 | from PyQt5.QtGui import * |
| 21 | +elif PYSIDE2: |
| 22 | + from PySide2.QtGui import * |
21 | 23 | elif PYQT4: |
| 24 | + try: |
| 25 | + # Older versions of PyQt4 do not provide these |
| 26 | + from PyQt4.QtGui import (QGlyphRun, QMatrix2x2, QMatrix2x3, |
| 27 | + QMatrix2x4, QMatrix3x2, QMatrix3x3, |
| 28 | + QMatrix3x4, QMatrix4x2, QMatrix4x3, |
| 29 | + QMatrix4x4, QTouchEvent, QQuaternion, |
| 30 | + QRadialGradient, QRawFont, QStaticText, |
| 31 | + QVector2D, QVector3D, QVector4D, |
| 32 | + qFuzzyCompare) |
| 33 | + except ImportError: |
| 34 | + pass |
22 | 35 | from PyQt4.Qt import QKeySequence, QTextCursor |
23 | 36 | from PyQt4.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap, |
24 | 37 | QBrush, QClipboard, QCloseEvent, QColor, |
25 | 38 | QConicalGradient, QContextMenuEvent, QCursor, |
26 | | - QDesktopServices, QDoubleValidator, QDrag, |
| 39 | + QDoubleValidator, QDrag, |
27 | 40 | QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent, |
28 | 41 | QDropEvent, QFileOpenEvent, QFocusEvent, QFont, |
29 | 42 | QFontDatabase, QFontInfo, QFontMetrics, |
30 | | - QFontMetricsF, QGlyphRun, QGradient, QHelpEvent, |
| 43 | + QFontMetricsF, QGradient, QHelpEvent, |
31 | 44 | QHideEvent, QHoverEvent, QIcon, QIconDragEvent, |
32 | 45 | QIconEngine, QImage, QImageIOHandler, QImageReader, |
33 | 46 | QImageWriter, QInputEvent, QInputMethodEvent, |
34 | 47 | QKeyEvent, QLinearGradient, |
35 | | - QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, |
36 | | - QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3, |
37 | | - QMatrix4x4, QMouseEvent, QMoveEvent, QMovie, |
| 48 | + QMouseEvent, QMoveEvent, QMovie, |
38 | 49 | QPaintDevice, QPaintEngine, QPaintEngineState, |
39 | 50 | QPaintEvent, QPainter, QPainterPath, |
40 | 51 | QPainterPathStroker, QPalette, QPen, QPicture, |
41 | 52 | QPictureIO, QPixmap, QPixmapCache, QPolygon, |
42 | | - QPolygonF, QQuaternion, QRadialGradient, QRawFont, |
43 | | - QRegExpValidator, QRegion, QResizeEvent, |
| 53 | + QPolygonF, QRegExpValidator, QRegion, QResizeEvent, |
44 | 54 | QSessionManager, QShortcutEvent, QShowEvent, |
45 | | - QStandardItem, QStandardItemModel, QStaticText, |
| 55 | + QStandardItem, QStandardItemModel, |
46 | 56 | QStatusTipEvent, QSyntaxHighlighter, QTabletEvent, |
47 | 57 | QTextBlock, QTextBlockFormat, QTextBlockGroup, |
48 | 58 | QTextBlockUserData, QTextCharFormat, |
|
53 | 63 | QTextLength, QTextLine, QTextList, QTextListFormat, |
54 | 64 | QTextObject, QTextObjectInterface, QTextOption, |
55 | 65 | QTextTable, QTextTableCell, QTextTableCellFormat, |
56 | | - QTextTableFormat, QTouchEvent, QTransform, |
57 | | - QValidator, QVector2D, QVector3D, QVector4D, |
58 | | - QWhatsThisClickedEvent, QWheelEvent, |
| 66 | + QTextTableFormat, QTransform, |
| 67 | + QValidator, QWhatsThisClickedEvent, QWheelEvent, |
59 | 68 | QWindowStateChangeEvent, qAlpha, qBlue, |
60 | | - qFuzzyCompare, qGray, qGreen, qIsGray, qRed, qRgb, |
| 69 | + qGray, qGreen, qIsGray, qRed, qRgb, |
61 | 70 | qRgba, QIntValidator) |
| 71 | + |
| 72 | + # QDesktopServices has has been split into (QDesktopServices and |
| 73 | + # QStandardPaths) in Qt5 |
| 74 | + # It only exposes QDesktopServices that are still in pyqt5 |
| 75 | + from PyQt4.QtGui import QDesktopServices as _QDesktopServices |
| 76 | + |
| 77 | + class QDesktopServices(): |
| 78 | + openUrl = _QDesktopServices.openUrl |
| 79 | + setUrlHandler = _QDesktopServices.setUrlHandler |
| 80 | + unsetUrlHandler = _QDesktopServices.unsetUrlHandler |
| 81 | + |
| 82 | + |
62 | 83 | elif PYSIDE: |
63 | 84 | from PySide.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap, |
64 | 85 | QBrush, QClipboard, QCloseEvent, QColor, |
65 | 86 | QConicalGradient, QContextMenuEvent, QCursor, |
66 | | - QDesktopServices, QDoubleValidator, QDrag, |
| 87 | + QDoubleValidator, QDrag, |
67 | 88 | QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent, |
68 | 89 | QDropEvent, QFileOpenEvent, QFocusEvent, QFont, |
69 | 90 | QFontDatabase, QFontInfo, QFontMetrics, |
|
99 | 120 | QWindowStateChangeEvent, qAlpha, qBlue, |
100 | 121 | qGray, qGreen, qIsGray, qRed, qRgb, qRgba, |
101 | 122 | QIntValidator) |
| 123 | + # QDesktopServices has has been split into (QDesktopServices and |
| 124 | + # QStandardPaths) in Qt5 |
| 125 | + # It only exposes QDesktopServices that are still in pyqt5 |
| 126 | + from PySide.QtGui import QDesktopServices as _QDesktopServices |
| 127 | + |
| 128 | + class QDesktopServices(): |
| 129 | + openUrl = _QDesktopServices.openUrl |
| 130 | + setUrlHandler = _QDesktopServices.setUrlHandler |
| 131 | + unsetUrlHandler = _QDesktopServices.unsetUrlHandler |
102 | 132 | else: |
103 | 133 | raise PythonQtError('No Qt bindings could be found') |
0 commit comments