github/workflows: update the darwin build for setuptools
[git-cola.git] / qtpy / QtWidgets.py
blob66ef3abad855d92cbd9aeca420172feab16a5db6
1 # -*- coding: utf-8 -*-
3 # Copyright © 2014-2015 Colin Duquesnoy
4 # Copyright © 2009- The Spyder Developmet Team
6 # Licensed under the terms of the MIT License
7 # (see LICENSE.txt for details)
9 """
10 Provides widget classes and functions.
11 .. warning:: Only PyQt4/PySide QtGui classes compatible with PyQt5.QtWidgets
12 are exposed here. Therefore, you need to treat/use this package as if it
13 were the ``PyQt5.QtWidgets`` module.
14 """
16 from . import PYQT5, PYSIDE2, PYQT4, PYSIDE, PythonQtError
17 from ._patch.qcombobox import patch_qcombobox
18 from ._patch.qheaderview import introduce_renamed_methods_qheaderview
21 if PYQT5:
22 from PyQt5.QtWidgets import *
23 elif PYSIDE2:
24 from PySide2.QtWidgets import *
25 elif PYQT4:
26 from PyQt4.QtGui import *
27 QStyleOptionViewItem = QStyleOptionViewItemV4
28 del QStyleOptionViewItemV4
29 QStyleOptionFrame = QStyleOptionFrameV3
30 del QStyleOptionFrameV3
32 # These objects belong to QtGui
33 try:
34 # Older versions of PyQt4 do not provide these
35 del (QGlyphRun,
36 QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, QMatrix3x3,
37 QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4,
38 QQuaternion, QRadialGradient, QRawFont, QRegExpValidator,
39 QStaticText, QTouchEvent, QVector2D, QVector3D, QVector4D,
40 qFuzzyCompare)
41 except NameError:
42 pass
43 del (QAbstractTextDocumentLayout, QActionEvent, QBitmap, QBrush, QClipboard,
44 QCloseEvent, QColor, QConicalGradient, QContextMenuEvent, QCursor,
45 QDesktopServices, QDoubleValidator, QDrag, QDragEnterEvent,
46 QDragLeaveEvent, QDragMoveEvent, QDropEvent, QFileOpenEvent,
47 QFocusEvent, QFont, QFontDatabase, QFontInfo, QFontMetrics,
48 QFontMetricsF, QGradient, QHelpEvent, QHideEvent,
49 QHoverEvent, QIcon, QIconDragEvent, QIconEngine, QImage,
50 QImageIOHandler, QImageReader, QImageWriter, QInputEvent,
51 QInputMethodEvent, QKeyEvent, QKeySequence, QLinearGradient,
52 QMouseEvent, QMoveEvent, QMovie, QPaintDevice, QPaintEngine,
53 QPaintEngineState, QPaintEvent, QPainter, QPainterPath,
54 QPainterPathStroker, QPalette, QPen, QPicture, QPictureIO, QPixmap,
55 QPixmapCache, QPolygon, QPolygonF,
56 QRegion, QResizeEvent, QSessionManager, QShortcutEvent, QShowEvent,
57 QStandardItem, QStandardItemModel, QStatusTipEvent,
58 QSyntaxHighlighter, QTabletEvent, QTextBlock, QTextBlockFormat,
59 QTextBlockGroup, QTextBlockUserData, QTextCharFormat, QTextCursor,
60 QTextDocument, QTextDocumentFragment, QTextDocumentWriter,
61 QTextFormat, QTextFragment, QTextFrame, QTextFrameFormat,
62 QTextImageFormat, QTextInlineObject, QTextItem, QTextLayout,
63 QTextLength, QTextLine, QTextList, QTextListFormat, QTextObject,
64 QTextObjectInterface, QTextOption, QTextTable, QTextTableCell,
65 QTextTableCellFormat, QTextTableFormat, QTransform,
66 QValidator, QWhatsThisClickedEvent,
67 QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue,
68 qGray, qGreen, qIsGray, qRed, qRgb, qRgba, QIntValidator,
69 QStringListModel)
71 # These objects belong to QtPrintSupport
72 del (QAbstractPrintDialog, QPageSetupDialog, QPrintDialog, QPrintEngine,
73 QPrintPreviewDialog, QPrintPreviewWidget, QPrinter, QPrinterInfo)
75 # These objects belong to QtCore
76 del (QItemSelection, QItemSelectionModel, QItemSelectionRange,
77 QSortFilterProxyModel)
79 # Patch QComboBox to allow Python objects to be passed to userData
80 patch_qcombobox(QComboBox)
82 # QHeaderView: renamed methods
83 introduce_renamed_methods_qheaderview(QHeaderView)
85 elif PYSIDE:
86 from PySide.QtGui import *
87 QStyleOptionViewItem = QStyleOptionViewItemV4
88 del QStyleOptionViewItemV4
90 # These objects belong to QtGui
91 del (QAbstractTextDocumentLayout, QActionEvent, QBitmap, QBrush, QClipboard,
92 QCloseEvent, QColor, QConicalGradient, QContextMenuEvent, QCursor,
93 QDesktopServices, QDoubleValidator, QDrag, QDragEnterEvent,
94 QDragLeaveEvent, QDragMoveEvent, QDropEvent, QFileOpenEvent,
95 QFocusEvent, QFont, QFontDatabase, QFontInfo, QFontMetrics,
96 QFontMetricsF, QGradient, QHelpEvent, QHideEvent,
97 QHoverEvent, QIcon, QIconDragEvent, QIconEngine, QImage,
98 QImageIOHandler, QImageReader, QImageWriter, QInputEvent,
99 QInputMethodEvent, QKeyEvent, QKeySequence, QLinearGradient,
100 QMatrix2x2, QMatrix2x3, QMatrix2x4, QMatrix3x2, QMatrix3x3,
101 QMatrix3x4, QMatrix4x2, QMatrix4x3, QMatrix4x4, QMouseEvent,
102 QMoveEvent, QMovie, QPaintDevice, QPaintEngine, QPaintEngineState,
103 QPaintEvent, QPainter, QPainterPath, QPainterPathStroker, QPalette,
104 QPen, QPicture, QPictureIO, QPixmap, QPixmapCache, QPolygon,
105 QPolygonF, QQuaternion, QRadialGradient, QRegExpValidator,
106 QRegion, QResizeEvent, QSessionManager, QShortcutEvent, QShowEvent,
107 QStandardItem, QStandardItemModel, QStatusTipEvent,
108 QSyntaxHighlighter, QTabletEvent, QTextBlock, QTextBlockFormat,
109 QTextBlockGroup, QTextBlockUserData, QTextCharFormat, QTextCursor,
110 QTextDocument, QTextDocumentFragment,
111 QTextFormat, QTextFragment, QTextFrame, QTextFrameFormat,
112 QTextImageFormat, QTextInlineObject, QTextItem, QTextLayout,
113 QTextLength, QTextLine, QTextList, QTextListFormat, QTextObject,
114 QTextObjectInterface, QTextOption, QTextTable, QTextTableCell,
115 QTextTableCellFormat, QTextTableFormat, QTouchEvent, QTransform,
116 QValidator, QVector2D, QVector3D, QVector4D, QWhatsThisClickedEvent,
117 QWheelEvent, QWindowStateChangeEvent, qAlpha, qBlue, qGray, qGreen,
118 qIsGray, qRed, qRgb, qRgba, QIntValidator, QStringListModel)
120 # These objects belong to QtPrintSupport
121 del (QAbstractPrintDialog, QPageSetupDialog, QPrintDialog, QPrintEngine,
122 QPrintPreviewDialog, QPrintPreviewWidget, QPrinter, QPrinterInfo)
124 # These objects belong to QtCore
125 del (QItemSelection, QItemSelectionModel, QItemSelectionRange,
126 QSortFilterProxyModel)
128 # Patch QComboBox to allow Python objects to be passed to userData
129 patch_qcombobox(QComboBox)
131 # QHeaderView: renamed methods
132 introduce_renamed_methods_qheaderview(QHeaderView)
134 else:
135 raise PythonQtError('No Qt bindings could be found')