diff --git a/piker/ui/qt.py b/piker/ui/qt.py new file mode 100644 index 00000000..9dbb971c --- /dev/null +++ b/piker/ui/qt.py @@ -0,0 +1,104 @@ +# piker: trading gear for hackers +# Copyright (C) Tyler Goodlet (in stewardship for pikers) + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +''' +Qt UI framework version shimming. + +Allow importing sub-pkgs from this module instead of worrying about +major version specifics, any enum moves or component renames. + +Code in `piker.ui.*` should always explicitlyimport directly from +this module like `from piker.ui.qt import ( ..` + +''' +from enum import EnumType + +from PyQt6 import ( + QtCore, + QtGui, + QtWidgets, +) +from PyQt6.QtCore import ( + Qt, + QCoreApplication, + QLineF, + QRectF, + # NOTE: for enums use the `.Type` subattr-space + QEvent, + QPointF, + QSize, + QModelIndex, + QItemSelectionModel, + pyqtBoundSignal, + pyqtRemoveInputHook, +) + +align_flag: EnumType = Qt.AlignmentFlag +txt_flag: EnumType = Qt.TextFlag +keys: EnumType = QEvent.Type +scrollbar_policy: EnumType = Qt.ScrollBarPolicy + +# ^-NOTE-^: handy snippet to discover enums: +# import enum +# [attr for attr_name in dir(QFrame) +# if (attr := getattr(QFrame, attr_name)) +# and isinstance(attr, enum.EnumType)] + +from PyQt6.QtGui import ( + QPainter, + QPainterPath, + QIcon, + QPixmap, + QColor, + QTransform, + QStandardItem, + QStandardItemModel, + QWheelEvent, + QScreen, + QCloseEvent, +) + +from PyQt6.QtWidgets import ( + QMainWindow, + QApplication, + QLabel, + QStatusBar, + QLineEdit, + QHBoxLayout, + QVBoxLayout, + QFormLayout, + QProgressBar, + QSizePolicy, + QStyledItemDelegate, + QStyleOptionViewItem, + QComboBox, + QWidget, + QFrame, + QSplitter, + QTreeView, + QStyle, + QGraphicsItem, + QGraphicsPathItem, + # QGraphicsView, + QStyleOptionGraphicsItem, + QGraphicsScene, + QGraphicsSceneMouseEvent, + QGraphicsProxyWidget, +) + +gs_keys: EnumType = QGraphicsSceneMouseEvent.Type +size_policy: EnumType = QtWidgets.QSizePolicy.Policy +px_cache_mode: EnumType = QGraphicsItem.CacheMode