Add `piker.ui.qt` as a `PyQt6` shim module
For the future, like if we ever get a `PyQt7` (or wtv else..), add a module which allows changing Qt binding lib imports from one spot for all other `.ui` submodules. In some sense this is like a shoddier, less dynamic version of how `pyqtgraph.Qt.__init__.py` supports multiple libs; it might actually make sense eventually to instead import from their shim layer instead? Included is a draft attempt at exposing a bunch of enums which under custom names: - while the specific grouping of values seem to always stay consistent, the root enum's seem to almost always get moved around in the `PyQtX` module namespace. - changing groupings and/or each top level enum's ns location can more simply be changed/re-orged from one spot. - allows `.ui` consumer code to use a name more relevant to `piker`'s usage of wtv UI component is being configured.pyqt6
parent
821e73a409
commit
d0170982bf
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
'''
|
||||||
|
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
|
Loading…
Reference in New Issue