Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cdf427

Browse files
author
stonebig
committed
vendored Qtpy-1.3
1 parent 5380dad commit 7cdf427

28 files changed

+410
-53
lines changed

winpython/_vendor/qtpy/QtCore.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Provides QtCore classes and functions.
1111
"""
1212

13-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
13+
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
1414

1515

1616
if PYQT5:
@@ -22,6 +22,8 @@
2222

2323
# Those are imported from `import *`
2424
del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR
25+
elif PYSIDE2:
26+
from PySide2.QtCore import *
2527
elif PYQT4:
2628
from PyQt4.QtCore import *
2729
# Those are things we inherited from Spyder that fix crazy crashes under
@@ -35,14 +37,58 @@
3537
QItemSelectionRange, QSortFilterProxyModel,
3638
QStringListModel)
3739
from PyQt4.QtCore import QT_VERSION_STR as __version__
40+
from PyQt4.QtCore import qInstallMsgHandler as qInstallMessageHandler
41+
42+
# QDesktopServices has has been split into (QDesktopServices and
43+
# QStandardPaths) in Qt5
44+
# This creates a dummy class that emulates QStandardPaths
45+
from PyQt4.QtGui import QDesktopServices as _QDesktopServices
46+
47+
class QStandardPaths():
48+
StandardLocation = _QDesktopServices.StandardLocation
49+
displayName = _QDesktopServices.displayName
50+
DesktopLocation = _QDesktopServices.DesktopLocation
51+
DocumentsLocation = _QDesktopServices.DocumentsLocation
52+
FontsLocation = _QDesktopServices.FontsLocation
53+
ApplicationsLocation = _QDesktopServices.ApplicationsLocation
54+
MusicLocation = _QDesktopServices.MusicLocation
55+
MoviesLocation = _QDesktopServices.MoviesLocation
56+
PicturesLocation = _QDesktopServices.PicturesLocation
57+
TempLocation = _QDesktopServices.TempLocation
58+
HomeLocation = _QDesktopServices.HomeLocation
59+
DataLocation = _QDesktopServices.DataLocation
60+
CacheLocation = _QDesktopServices.CacheLocation
3861

3962
# Those are imported from `import *`
40-
del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR
63+
del pyqtSignal, pyqtSlot, pyqtProperty, QT_VERSION_STR, qInstallMsgHandler
4164
elif PYSIDE:
4265
from PySide.QtCore import *
4366
from PySide.QtGui import (QItemSelection, QItemSelectionModel,
4467
QItemSelectionRange, QSortFilterProxyModel,
4568
QStringListModel)
69+
from PySide.QtCore import qInstallMsgHandler as qInstallMessageHandler
70+
del qInstallMsgHandler
71+
72+
# QDesktopServices has has been split into (QDesktopServices and
73+
# QStandardPaths) in Qt5
74+
# This creates a dummy class that emulates QStandardPaths
75+
from PySide.QtGui import QDesktopServices as _QDesktopServices
76+
77+
class QStandardPaths():
78+
StandardLocation = _QDesktopServices.StandardLocation
79+
displayName = _QDesktopServices.displayName
80+
DesktopLocation = _QDesktopServices.DesktopLocation
81+
DocumentsLocation = _QDesktopServices.DocumentsLocation
82+
FontsLocation = _QDesktopServices.FontsLocation
83+
ApplicationsLocation = _QDesktopServices.ApplicationsLocation
84+
MusicLocation = _QDesktopServices.MusicLocation
85+
MoviesLocation = _QDesktopServices.MoviesLocation
86+
PicturesLocation = _QDesktopServices.PicturesLocation
87+
TempLocation = _QDesktopServices.TempLocation
88+
HomeLocation = _QDesktopServices.HomeLocation
89+
DataLocation = _QDesktopServices.DataLocation
90+
CacheLocation = _QDesktopServices.CacheLocation
91+
4692
import PySide.QtCore
4793
__version__ = PySide.QtCore.__version__
4894
else:

winpython/_vendor/qtpy/QtGui.py

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,46 @@
1313
the ``PyQt5.QtGui`` module.
1414
"""
1515

16-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
16+
from . import PYQT5, PYQT4, PYSIDE, PYSIDE2, PythonQtError
1717

1818

1919
if PYQT5:
2020
from PyQt5.QtGui import *
21+
elif PYSIDE2:
22+
from PySide2.QtGui import *
2123
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
2235
from PyQt4.Qt import QKeySequence, QTextCursor
2336
from PyQt4.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
2437
QBrush, QClipboard, QCloseEvent, QColor,
2538
QConicalGradient, QContextMenuEvent, QCursor,
26-
QDesktopServices, QDoubleValidator, QDrag,
39+
QDoubleValidator, QDrag,
2740
QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
2841
QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
2942
QFontDatabase, QFontInfo, QFontMetrics,
30-
QFontMetricsF, QGlyphRun, QGradient, QHelpEvent,
43+
QFontMetricsF, QGradient, QHelpEvent,
3144
QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
3245
QIconEngine, QImage, QImageIOHandler, QImageReader,
3346
QImageWriter, QInputEvent, QInputMethodEvent,
3447
QKeyEvent, QLinearGradient,
35-
QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2,
36-
QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3,
37-
QMatrix4x4, QMouseEvent, QMoveEvent, QMovie,
48+
QMouseEvent, QMoveEvent, QMovie,
3849
QPaintDevice, QPaintEngine, QPaintEngineState,
3950
QPaintEvent, QPainter, QPainterPath,
4051
QPainterPathStroker, QPalette, QPen, QPicture,
4152
QPictureIO, QPixmap, QPixmapCache, QPolygon,
42-
QPolygonF, QQuaternion, QRadialGradient, QRawFont,
43-
QRegExpValidator, QRegion, QResizeEvent,
53+
QPolygonF, QRegExpValidator, QRegion, QResizeEvent,
4454
QSessionManager, QShortcutEvent, QShowEvent,
45-
QStandardItem, QStandardItemModel, QStaticText,
55+
QStandardItem, QStandardItemModel,
4656
QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
4757
QTextBlock, QTextBlockFormat, QTextBlockGroup,
4858
QTextBlockUserData, QTextCharFormat,
@@ -53,17 +63,28 @@
5363
QTextLength, QTextLine, QTextList, QTextListFormat,
5464
QTextObject, QTextObjectInterface, QTextOption,
5565
QTextTable, QTextTableCell, QTextTableCellFormat,
56-
QTextTableFormat, QTouchEvent, QTransform,
57-
QValidator, QVector2D, QVector3D, QVector4D,
58-
QWhatsThisClickedEvent, QWheelEvent,
66+
QTextTableFormat, QTransform,
67+
QValidator, QWhatsThisClickedEvent, QWheelEvent,
5968
QWindowStateChangeEvent, qAlpha, qBlue,
60-
qFuzzyCompare, qGray, qGreen, qIsGray, qRed, qRgb,
69+
qGray, qGreen, qIsGray, qRed, qRgb,
6170
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+
6283
elif PYSIDE:
6384
from PySide.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
6485
QBrush, QClipboard, QCloseEvent, QColor,
6586
QConicalGradient, QContextMenuEvent, QCursor,
66-
QDesktopServices, QDoubleValidator, QDrag,
87+
QDoubleValidator, QDrag,
6788
QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
6889
QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
6990
QFontDatabase, QFontInfo, QFontMetrics,
@@ -99,5 +120,14 @@
99120
QWindowStateChangeEvent, qAlpha, qBlue,
100121
qGray, qGreen, qIsGray, qRed, qRgb, qRgba,
101122
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
102132
else:
103133
raise PythonQtError('No Qt bindings could be found')

winpython/_vendor/qtpy/QtMultimedia.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
from . import PYQT5
22
from . import PYQT4
33
from . import PYSIDE
4+
from . import PYSIDE2
45

56

67
if PYQT5:
78
from PyQt5.QtMultimedia import *
9+
elif PYSIDE2:
10+
# Current wheels don't have this module
11+
# from PySide2.QtMultimedia import *
12+
pass
813
elif PYQT4:
914
from PyQt4.QtMultimedia import *
1015
from PyQt4.QtGui import QSound

winpython/_vendor/qtpy/QtNetwork.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
Provides QtNetwork classes and functions.
1111
"""
1212

13-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
13+
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
1414

1515

1616
if PYQT5:
1717
from PyQt5.QtNetwork import *
18+
elif PYSIDE2:
19+
from PySide2.QtNetwork import *
1820
elif PYQT4:
1921
from PyQt4.QtNetwork import *
2022
elif PYSIDE:

winpython/_vendor/qtpy/QtOpenGL.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
# -----------------------------------------------------------------------------
3+
# Copyright © 2009- The Spyder Development Team
4+
#
5+
# Licensed under the terms of the MIT License
6+
# (see LICENSE.txt for details)
7+
# -----------------------------------------------------------------------------
8+
"""Provides QtOpenGL classes and functions."""
9+
10+
# Local imports
11+
from . import PYQT4, PYQT5, PYSIDE, PythonQtError
12+
13+
if PYQT5:
14+
from PyQt5.QtOpenGL import *
15+
elif PYQT4:
16+
from PyQt4.QtOpenGL import *
17+
elif PYSIDE:
18+
from PySide.QtOpenGL import *
19+
else:
20+
raise PythonQtError('No Qt bindings could be found')
21+
22+
del PYQT4, PYQT5, PYSIDE

winpython/_vendor/qtpy/QtPrintSupport.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
Provides QtPrintSupport classes and functions.
1010
"""
1111

12-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
12+
from . import PYQT5, PYQT4,PYSIDE2, PYSIDE, PythonQtError
1313

1414

1515
if PYQT5:
1616
from PyQt5.QtPrintSupport import *
17+
elif PYSIDE2:
18+
from PySide2.QtPrintSupport import *
1719
elif PYQT4:
1820
from PyQt4.QtGui import (QAbstractPrintDialog, QPageSetupDialog,
1921
QPrintDialog, QPrintEngine, QPrintPreviewDialog,

winpython/_vendor/qtpy/QtSvg.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
"""Provides QtSvg classes and functions."""
99

1010
# Local imports
11-
from . import PYQT4, PYQT5, PYSIDE, PythonQtError
11+
from . import PYQT4, PYSIDE2, PYQT5, PYSIDE, PythonQtError
1212

1313
if PYQT5:
1414
from PyQt5.QtSvg import *
15+
elif PYSIDE2:
16+
from PySide2.QtSvg import *
1517
elif PYQT4:
1618
from PyQt4.QtSvg import *
1719
elif PYSIDE:
1820
from PySide.QtSvg import *
1921
else:
2022
raise PythonQtError('No Qt bindings could be found')
2123

22-
del PYQT4, PYQT5, PYSIDE
24+
del PYQT4, PYQT5, PYSIDE, PYSIDE2

winpython/_vendor/qtpy/QtTest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
Provides QtTest and functions
1111
"""
1212

13-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
13+
from . import PYQT5,PYSIDE2, PYQT4, PYSIDE, PythonQtError
1414

1515

1616
if PYQT5:
1717
from PyQt5.QtTest import QTest
18+
elif PYSIDE2:
19+
from PySide2.QtTest import QTest
1820
elif PYQT4:
1921
from PyQt4.QtTest import QTest as OldQTest
2022

winpython/_vendor/qtpy/QtWebEngineWidgets.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Provides QtWebEngineWidgets classes and functions.
1111
"""
1212

13-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
13+
from . import PYQT5,PYSIDE2, PYQT4, PYSIDE, PythonQtError
1414

1515

1616
# To test if we are using WebEngine or WebKit
@@ -27,6 +27,18 @@
2727
from PyQt5.QtWebKitWidgets import QWebView as QWebEngineView
2828
from PyQt5.QtWebKit import QWebSettings as QWebEngineSettings
2929
WEBENGINE = False
30+
elif PYSIDE2:
31+
try:
32+
from PySide2.QtWebEngineWidgets import QWebEnginePage
33+
from PySide2.QtWebEngineWidgets import QWebEngineView
34+
# Current PySide2 wheels seem to be missing this.
35+
# from PySide2.QtWebEngineWidgets import QWebEngineSettings
36+
except ImportError:
37+
from PySide2.QtWebKitWidgets import QWebPage as QWebEnginePage
38+
from PySide2.QtWebKitWidgets import QWebView as QWebEngineView
39+
# Current PySide2 wheels seem to be missing this.
40+
# from PySide2.QtWebKit import QWebSettings as QWebEngineSettings
41+
WEBENGINE = False
3042
elif PYQT4:
3143
from PyQt4.QtWebKit import QWebPage as QWebEnginePage
3244
from PyQt4.QtWebKit import QWebView as QWebEngineView

winpython/_vendor/qtpy/QtWidgets.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,56 @@
1313
were the ``PyQt5.QtWidgets`` module.
1414
"""
1515

16-
from . import PYQT5, PYQT4, PYSIDE, PythonQtError
16+
from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
1717
from ._patch.qcombobox import patch_qcombobox
1818
from ._patch.qheaderview import introduce_renamed_methods_qheaderview
1919

2020

2121
if PYQT5:
2222
from PyQt5.QtWidgets import *
23+
elif PYSIDE2:
24+
from PySide2.QtWidgets import *
2325
elif PYQT4:
2426
from PyQt4.QtGui import *
2527
QStyleOptionViewItem = QStyleOptionViewItemV4
2628
del QStyleOptionViewItemV4
2729

2830
# These objects belong to QtGui
31+
try:
32+
# Older versions of PyQt4 do not provide these
33+
del (QGlyphRun,
34+
QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, QMatrix3x3,
35+
QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4,
36+
QQuaternion, QRadialGradient, QRawFont, QRegExpValidator,
37+
QStaticText, QTouchEvent, QVector2D, QVector3D, QVector4D,
38+
qFuzzyCompare)
39+
except NameError:
40+
pass
2941
del (QAbstractTextDocumentLayout, QActionEvent, QBitmap, QBrush, QClipboard,
3042
QCloseEvent, QColor, QConicalGradient, QContextMenuEvent, QCursor,
3143
QDesktopServices, QDoubleValidator, QDrag, QDragEnterEvent,
3244
QDragLeaveEvent, QDragMoveEvent, QDropEvent, QFileOpenEvent,
3345
QFocusEvent, QFont, QFontDatabase, QFontInfo, QFontMetrics,
34-
QFontMetricsF, QGlyphRun, QGradient, QHelpEvent, QHideEvent,
46+
QFontMetricsF, QGradient, QHelpEvent, QHideEvent,
3547
QHoverEvent, QIcon, QIconDragEvent, QIconEngine, QImage,
3648
QImageIOHandler, QImageReader, QImageWriter, QInputEvent,
3749
QInputMethodEvent, QKeyEvent, QKeySequence, QLinearGradient,
38-
QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, QMatrix3x3,
39-
QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4, QMouseEvent,
40-
QMoveEvent, QMovie, QPaintDevice, QPaintEngine, QPaintEngineState,
41-
QPaintEvent, QPainter, QPainterPath, QPainterPathStroker, QPalette,
42-
QPen, QPicture, QPictureIO, QPixmap, QPixmapCache, QPolygon,
43-
QPolygonF, QQuaternion, QRadialGradient, QRawFont, QRegExpValidator,
50+
QMouseEvent, QMoveEvent, QMovie, QPaintDevice, QPaintEngine,
51+
QPaintEngineState, QPaintEvent, QPainter, QPainterPath,
52+
QPainterPathStroker, QPalette, QPen, QPicture, QPictureIO, QPixmap,
53+
QPixmapCache, QPolygon, QPolygonF,
4454
QRegion, QResizeEvent, QSessionManager, QShortcutEvent, QShowEvent,
45-
QStandardItem, QStandardItemModel, QStaticText, QStatusTipEvent,
55+
QStandardItem, QStandardItemModel, QStatusTipEvent,
4656
QSyntaxHighlighter, QTabletEvent, QTextBlock, QTextBlockFormat,
4757
QTextBlockGroup, QTextBlockUserData, QTextCharFormat, QTextCursor,
4858
QTextDocument, QTextDocumentFragment, QTextDocumentWriter,
4959
QTextFormat, QTextFragment, QTextFrame, QTextFrameFormat,
5060
QTextImageFormat, QTextInlineObject, QTextItem, QTextLayout,
5161
QTextLength, QTextLine, QTextList, QTextListFormat, QTextObject,
5262
QTextObjectInterface, QTextOption, QTextTable, QTextTableCell,
53-
QTextTableCellFormat, QTextTableFormat, QTouchEvent, QTransform,
54-
QValidator, QVector2D, QVector3D, QVector4D, QWhatsThisClickedEvent,
55-
QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue, qFuzzyCompare,
63+
QTextTableCellFormat, QTextTableFormat, QTransform,
64+
QValidator, QWhatsThisClickedEvent,
65+
QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue,
5666
qGray, qGreen, qIsGray, qRed, qRgb, qRgba, QIntValidator,
5767
QStringListModel)
5868

0 commit comments

Comments
 (0)