You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
6.2 KiB

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