`PyQt5` + `pyqtgraph` import updates (`QtGui -> `QtWidgets`)
parent
11ecf9cb09
commit
5976acbe76
|
@ -111,7 +111,8 @@ class LevelMarker(QGraphicsPathItem):
|
|||
|
||||
# get polygon and scale
|
||||
super().__init__()
|
||||
self.scale(size, size)
|
||||
# self.setScale(size, size)
|
||||
self.setScale(size)
|
||||
|
||||
# interally generates path
|
||||
self._style = None
|
||||
|
|
|
@ -26,7 +26,19 @@ from typing import (
|
|||
)
|
||||
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph import ViewBox, Point, QtCore, QtGui
|
||||
from pyqtgraph import (
|
||||
ViewBox,
|
||||
Point,
|
||||
QtCore,
|
||||
QtWidgets,
|
||||
)
|
||||
from PyQt5.QtGui import (
|
||||
QColor,
|
||||
)
|
||||
from PyQt5.QtWidgets import (
|
||||
QLabel,
|
||||
)
|
||||
|
||||
from pyqtgraph import functions as fn
|
||||
from PyQt5.QtCore import QPointF
|
||||
import numpy as np
|
||||
|
@ -240,7 +252,7 @@ class LineEditor(Struct):
|
|||
return lines
|
||||
|
||||
|
||||
class SelectRect(QtGui.QGraphicsRectItem):
|
||||
class SelectRect(QtWidgets.QGraphicsRectItem):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -249,12 +261,12 @@ class SelectRect(QtGui.QGraphicsRectItem):
|
|||
) -> None:
|
||||
super().__init__(0, 0, 1, 1)
|
||||
|
||||
# self.rbScaleBox = QtGui.QGraphicsRectItem(0, 0, 1, 1)
|
||||
# self.rbScaleBox = QGraphicsRectItem(0, 0, 1, 1)
|
||||
self.vb = viewbox
|
||||
self._chart: 'ChartPlotWidget' = None # noqa
|
||||
|
||||
# override selection box color
|
||||
color = QtGui.QColor(hcolor(color))
|
||||
color = QColor(hcolor(color))
|
||||
self.setPen(fn.mkPen(color, width=1))
|
||||
color.setAlpha(66)
|
||||
self.setBrush(fn.mkBrush(color))
|
||||
|
@ -262,7 +274,7 @@ class SelectRect(QtGui.QGraphicsRectItem):
|
|||
self.hide()
|
||||
self._label = None
|
||||
|
||||
label = self._label = QtGui.QLabel()
|
||||
label = self._label = QLabel()
|
||||
label.setTextFormat(0) # markdown
|
||||
label.setFont(_font.font)
|
||||
label.setMargin(0)
|
||||
|
@ -299,8 +311,8 @@ class SelectRect(QtGui.QGraphicsRectItem):
|
|||
# TODO: get bg color working
|
||||
palette.setColor(
|
||||
self._label.backgroundRole(),
|
||||
# QtGui.QColor(chart.backgroundBrush()),
|
||||
QtGui.QColor(hcolor('papas_special')),
|
||||
# QColor(chart.backgroundBrush()),
|
||||
QColor(hcolor('papas_special')),
|
||||
)
|
||||
|
||||
def update_on_resize(self, vr, r):
|
||||
|
|
|
@ -20,19 +20,24 @@ Trio - Qt integration
|
|||
Run ``trio`` in guest mode on top of the Qt event loop.
|
||||
All global Qt runtime settings are mostly defined here.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import (
|
||||
Callable,
|
||||
Any,
|
||||
Type,
|
||||
TYPE_CHECKING,
|
||||
)
|
||||
import platform
|
||||
import traceback
|
||||
|
||||
# Qt specific
|
||||
import PyQt5 # noqa
|
||||
from pyqtgraph import QtGui
|
||||
from PyQt5.QtWidgets import (
|
||||
QWidget,
|
||||
QMainWindow,
|
||||
QApplication,
|
||||
)
|
||||
from PyQt5 import QtCore
|
||||
# from PyQt5.QtGui import QLabel, QStatusBar
|
||||
from PyQt5.QtCore import (
|
||||
pyqtRemoveInputHook,
|
||||
Qt,
|
||||
|
@ -49,6 +54,7 @@ from ..log import get_logger
|
|||
from ._pg_overrides import _do_overrides
|
||||
from . import _style
|
||||
|
||||
|
||||
log = get_logger(__name__)
|
||||
|
||||
# pyqtgraph global config
|
||||
|
@ -76,17 +82,17 @@ if platform.system() == "Windows":
|
|||
def run_qtractor(
|
||||
func: Callable,
|
||||
args: tuple,
|
||||
main_widget_type: Type[QtGui.QWidget],
|
||||
main_widget_type: Type[QWidget],
|
||||
tractor_kwargs: dict[str, Any] = {},
|
||||
window_type: QtGui.QMainWindow = None,
|
||||
window_type: QMainWindow = None,
|
||||
|
||||
) -> None:
|
||||
# avoids annoying message when entering debugger from qt loop
|
||||
pyqtRemoveInputHook()
|
||||
|
||||
app = QtGui.QApplication.instance()
|
||||
app = QApplication.instance()
|
||||
if app is None:
|
||||
app = PyQt5.QtWidgets.QApplication([])
|
||||
app = QApplication([])
|
||||
|
||||
# TODO: we might not need this if it's desired
|
||||
# to cancel the tractor machinery on Qt loop
|
||||
|
|
|
@ -32,6 +32,7 @@ from PyQt5.QtGui import QPainterPath
|
|||
from .._profile import pg_profile_enabled, ms_slower_then
|
||||
from ._style import hcolor
|
||||
from ..log import get_logger
|
||||
from .._profile import Profiler
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ._chart import LinkedSplits
|
||||
|
@ -170,7 +171,7 @@ class BarItems(pg.GraphicsObject):
|
|||
|
||||
) -> None:
|
||||
|
||||
profiler = pg.debug.Profiler(
|
||||
profiler = Profiler(
|
||||
disabled=not pg_profile_enabled(),
|
||||
ms_threshold=ms_slower_then,
|
||||
)
|
||||
|
|
|
@ -28,10 +28,19 @@ from typing import (
|
|||
)
|
||||
import uuid
|
||||
|
||||
from pyqtgraph import QtGui
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtWidgets import QLabel, QStatusBar
|
||||
from PyQt5.QtWidgets import (
|
||||
QWidget,
|
||||
QMainWindow,
|
||||
QApplication,
|
||||
QLabel,
|
||||
QStatusBar,
|
||||
)
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QScreen,
|
||||
QCloseEvent,
|
||||
)
|
||||
from ..log import get_logger
|
||||
from ._style import _font_small, hcolor
|
||||
from ._chart import GodWidget
|
||||
|
@ -153,7 +162,7 @@ class MultiStatus:
|
|||
self.bar.clearMessage()
|
||||
|
||||
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
class MainWindow(QMainWindow):
|
||||
|
||||
# XXX: for tiling wms this should scale
|
||||
# with the alloted window size.
|
||||
|
@ -176,12 +185,12 @@ class MainWindow(QtGui.QMainWindow):
|
|||
self._size: Optional[tuple[int, int]] = None
|
||||
|
||||
@property
|
||||
def mode_label(self) -> QtGui.QLabel:
|
||||
def mode_label(self) -> QLabel:
|
||||
|
||||
# init mode label
|
||||
if not self._status_label:
|
||||
|
||||
self._status_label = label = QtGui.QLabel()
|
||||
self._status_label = label = QLabel()
|
||||
label.setStyleSheet(
|
||||
f"""QLabel {{
|
||||
color : {hcolor('gunmetal')};
|
||||
|
@ -203,8 +212,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||
|
||||
def closeEvent(
|
||||
self,
|
||||
|
||||
event: QtGui.QCloseEvent,
|
||||
event: QCloseEvent,
|
||||
|
||||
) -> None:
|
||||
'''Cancel the root actor asap.
|
||||
|
@ -244,8 +252,8 @@ class MainWindow(QtGui.QMainWindow):
|
|||
def on_focus_change(
|
||||
self,
|
||||
|
||||
last: QtGui.QWidget,
|
||||
current: QtGui.QWidget,
|
||||
last: QWidget,
|
||||
current: QWidget,
|
||||
|
||||
) -> None:
|
||||
|
||||
|
@ -256,12 +264,12 @@ class MainWindow(QtGui.QMainWindow):
|
|||
name = getattr(current, 'mode_name', '')
|
||||
self.set_mode_name(name)
|
||||
|
||||
def current_screen(self) -> QtGui.QScreen:
|
||||
def current_screen(self) -> QScreen:
|
||||
'''
|
||||
Get a frickin screen (if we can, gawd).
|
||||
|
||||
'''
|
||||
app = QtGui.QApplication.instance()
|
||||
app = QApplication.instance()
|
||||
|
||||
for _ in range(3):
|
||||
screen = app.screenAt(self.pos())
|
||||
|
@ -294,7 +302,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||
'''
|
||||
# https://stackoverflow.com/a/18975846
|
||||
if not size and not self._size:
|
||||
# app = QtGui.QApplication.instance()
|
||||
# app = QApplication.instance()
|
||||
geo = self.current_screen().geometry()
|
||||
h, w = geo.height(), geo.width()
|
||||
# use approx 1/3 of the area of the screen by default
|
||||
|
@ -331,7 +339,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||
|
||||
|
||||
# singleton app per actor
|
||||
_qt_win: QtGui.QMainWindow = None
|
||||
_qt_win: QMainWindow = None
|
||||
|
||||
|
||||
def main_window() -> MainWindow:
|
||||
|
|
Loading…
Reference in New Issue