extras: fix pylint/flake8 violations
[git-cola.git] / qtpy / QtGui.py
blobbe8f568865316c891bfaf24b27a313f51e3a8f1f
1 # -*- coding: utf-8 -*-
3 # Copyright © 2014-2015 Colin Duquesnoy
4 # Copyright © 2009- The Spyder Development Team
6 # Licensed under the terms of the MIT License
7 # (see LICENSE.txt for details)
9 """
10 Provides QtGui classes and functions.
11 .. warning:: Only PyQt4/PySide QtGui classes compatible with PyQt5.QtGui are
12 exposed here. Therefore, you need to treat/use this package as if it were
13 the ``PyQt5.QtGui`` module.
14 """
15 import warnings
17 from . import PYQT5, PYQT4, PYSIDE, PYSIDE2, PythonQtError
20 if PYQT5:
21 from PyQt5.QtGui import *
22 elif PYSIDE2:
23 from PySide2.QtGui import *
24 elif PYQT4:
25 try:
26 # Older versions of PyQt4 do not provide these
27 from PyQt4.QtGui import (QGlyphRun, QMatrix2x2, QMatrix2x3,
28 QMatrix2x4, QMatrix3x2, QMatrix3x3,
29 QMatrix3x4, QMatrix4x2, QMatrix4x3,
30 QMatrix4x4, QTouchEvent, QQuaternion,
31 QRadialGradient, QRawFont, QStaticText,
32 QVector2D, QVector3D, QVector4D,
33 qFuzzyCompare)
34 except ImportError:
35 pass
36 try:
37 from PyQt4.Qt import QKeySequence, QTextCursor
38 except ImportError:
39 # In PyQt4-sip 4.19.13 QKeySequence and QTextCursor are in PyQt4.QtGui
40 from PyQt4.QtGui import QKeySequence, QTextCursor
41 from PyQt4.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
42 QBrush, QClipboard, QCloseEvent, QColor,
43 QConicalGradient, QContextMenuEvent, QCursor,
44 QDoubleValidator, QDrag,
45 QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
46 QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
47 QFontDatabase, QFontInfo, QFontMetrics,
48 QFontMetricsF, QGradient, QHelpEvent,
49 QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
50 QIconEngine, QImage, QImageIOHandler, QImageReader,
51 QImageWriter, QInputEvent, QInputMethodEvent,
52 QKeyEvent, QLinearGradient,
53 QMouseEvent, QMoveEvent, QMovie,
54 QPaintDevice, QPaintEngine, QPaintEngineState,
55 QPaintEvent, QPainter, QPainterPath,
56 QPainterPathStroker, QPalette, QPen, QPicture,
57 QPictureIO, QPixmap, QPixmapCache, QPolygon,
58 QPolygonF, QRegExpValidator, QRegion, QResizeEvent,
59 QSessionManager, QShortcutEvent, QShowEvent,
60 QStandardItem, QStandardItemModel,
61 QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
62 QTextBlock, QTextBlockFormat, QTextBlockGroup,
63 QTextBlockUserData, QTextCharFormat,
64 QTextDocument, QTextDocumentFragment,
65 QTextDocumentWriter, QTextFormat, QTextFragment,
66 QTextFrame, QTextFrameFormat, QTextImageFormat,
67 QTextInlineObject, QTextItem, QTextLayout,
68 QTextLength, QTextLine, QTextList, QTextListFormat,
69 QTextObject, QTextObjectInterface, QTextOption,
70 QTextTable, QTextTableCell, QTextTableCellFormat,
71 QTextTableFormat, QTransform,
72 QValidator, QWhatsThisClickedEvent, QWheelEvent,
73 QWindowStateChangeEvent, qAlpha, qBlue,
74 qGray, qGreen, qIsGray, qRed, qRgb,
75 qRgba, QIntValidator)
77 # QDesktopServices has has been split into (QDesktopServices and
78 # QStandardPaths) in Qt5
79 # It only exposes QDesktopServices that are still in pyqt5
80 from PyQt4.QtGui import QDesktopServices as _QDesktopServices
82 class QDesktopServices():
83 openUrl = _QDesktopServices.openUrl
84 setUrlHandler = _QDesktopServices.setUrlHandler
85 unsetUrlHandler = _QDesktopServices.unsetUrlHandler
87 def __getattr__(self, name):
88 attr = getattr(_QDesktopServices, name)
90 new_name = name
91 if name == 'storageLocation':
92 new_name = 'writableLocation'
93 warnings.warn(("Warning QDesktopServices.{} is deprecated in Qt5"
94 "we recommend you use QDesktopServices.{} instead").format(name, new_name),
95 DeprecationWarning)
96 return attr
97 QDesktopServices = QDesktopServices()
99 elif PYSIDE:
100 from PySide.QtGui import (QAbstractTextDocumentLayout, QActionEvent, QBitmap,
101 QBrush, QClipboard, QCloseEvent, QColor,
102 QConicalGradient, QContextMenuEvent, QCursor,
103 QDoubleValidator, QDrag,
104 QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent,
105 QDropEvent, QFileOpenEvent, QFocusEvent, QFont,
106 QFontDatabase, QFontInfo, QFontMetrics,
107 QFontMetricsF, QGradient, QHelpEvent,
108 QHideEvent, QHoverEvent, QIcon, QIconDragEvent,
109 QIconEngine, QImage, QImageIOHandler, QImageReader,
110 QImageWriter, QInputEvent, QInputMethodEvent,
111 QKeyEvent, QKeySequence, QLinearGradient,
112 QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2,
113 QMatrix3x3, QMatrix3x4, QMatrix4x2, QMatrix4x3,
114 QMatrix4x4, QMouseEvent, QMoveEvent, QMovie,
115 QPaintDevice, QPaintEngine, QPaintEngineState,
116 QPaintEvent, QPainter, QPainterPath,
117 QPainterPathStroker, QPalette, QPen, QPicture,
118 QPictureIO, QPixmap, QPixmapCache, QPolygon,
119 QPolygonF, QQuaternion, QRadialGradient,
120 QRegExpValidator, QRegion, QResizeEvent,
121 QSessionManager, QShortcutEvent, QShowEvent,
122 QStandardItem, QStandardItemModel,
123 QStatusTipEvent, QSyntaxHighlighter, QTabletEvent,
124 QTextBlock, QTextBlockFormat, QTextBlockGroup,
125 QTextBlockUserData, QTextCharFormat, QTextCursor,
126 QTextDocument, QTextDocumentFragment,
127 QTextFormat, QTextFragment,
128 QTextFrame, QTextFrameFormat, QTextImageFormat,
129 QTextInlineObject, QTextItem, QTextLayout,
130 QTextLength, QTextLine, QTextList, QTextListFormat,
131 QTextObject, QTextObjectInterface, QTextOption,
132 QTextTable, QTextTableCell, QTextTableCellFormat,
133 QTextTableFormat, QTouchEvent, QTransform,
134 QValidator, QVector2D, QVector3D, QVector4D,
135 QWhatsThisClickedEvent, QWheelEvent,
136 QWindowStateChangeEvent, qAlpha, qBlue,
137 qGray, qGreen, qIsGray, qRed, qRgb, qRgba,
138 QIntValidator)
139 # QDesktopServices has has been split into (QDesktopServices and
140 # QStandardPaths) in Qt5
141 # It only exposes QDesktopServices that are still in pyqt5
142 from PySide.QtGui import QDesktopServices as _QDesktopServices
144 class QDesktopServices():
145 openUrl = _QDesktopServices.openUrl
146 setUrlHandler = _QDesktopServices.setUrlHandler
147 unsetUrlHandler = _QDesktopServices.unsetUrlHandler
149 def __getattr__(self, name):
150 attr = getattr(_QDesktopServices, name)
152 new_name = name
153 if name == 'storageLocation':
154 new_name = 'writableLocation'
155 warnings.warn(("Warning QDesktopServices.{} is deprecated in Qt5"
156 "we recommend you use QDesktopServices.{} instead").format(name, new_name),
157 DeprecationWarning)
158 return attr
159 QDesktopServices = QDesktopServices()
160 else:
161 raise PythonQtError('No Qt bindings could be found')