Fix a few QtGui -> QtWidget issues

brokers_config
Conrad Steenberg 2021-07-21 12:50:09 -07:00
parent 161089de87
commit 3912b22b41
12 changed files with 47 additions and 43 deletions

1
.gitignore vendored
View File

@ -99,3 +99,4 @@ ENV/
# mypy # mypy
.mypy_cache/ .mypy_cache/
.vscode/settings.json

View File

@ -18,8 +18,9 @@
Annotations for ur faces. Annotations for ur faces.
""" """
import PyQt5
from PyQt5 import QtCore, QtGui from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import QGraphicsPathItem from PyQt5.QtWidgets import QGraphicsPathItem
from pyqtgraph import Point, functions as fn, Color from pyqtgraph import Point, functions as fn, Color
import numpy as np import numpy as np

View File

@ -47,7 +47,7 @@ class Axis(pg.AxisItem):
super().__init__(**kwargs) super().__init__(**kwargs)
# XXX: pretty sure this makes things slower # XXX: pretty sure this makes things slower
# self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) # self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
self.linkedsplits = linkedsplits self.linkedsplits = linkedsplits
self._min_tick = min_tick self._min_tick = min_tick
@ -185,7 +185,7 @@ class AxisLabel(pg.GraphicsObject):
self.setFlag(self.ItemIgnoresTransformations) self.setFlag(self.ItemIgnoresTransformations)
# XXX: pretty sure this is faster # XXX: pretty sure this is faster
self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
self._parent = parent self._parent = parent
@ -218,7 +218,7 @@ class AxisLabel(pg.GraphicsObject):
Subtypes can customize further by overloading ``.draw()``. Subtypes can customize further by overloading ``.draw()``.
""" """
# p.setCompositionMode(QtGui.QPainter.CompositionMode_SourceOver) # p.setCompositionMode(QtWidgets.QPainter.CompositionMode_SourceOver)
if self.label_str: if self.label_str:
@ -351,7 +351,7 @@ class XAxisLabel(AxisLabel):
def _draw_arrow_path(self): def _draw_arrow_path(self):
y_offset = self._parent.style['tickTextOffset'][1] y_offset = self._parent.style['tickTextOffset'][1]
path = QtGui.QPainterPath() path = QtWidgets.QPainterPath()
h, w = self.rect.height(), self.rect.width() h, w = self.rect.height(), self.rect.width()
middle = w/2 - 0.5 middle = w/2 - 0.5
aw = h/2 aw = h/2
@ -453,7 +453,7 @@ class YAxisLabel(AxisLabel):
def _draw_arrow_path(self): def _draw_arrow_path(self):
x_offset = self._parent.style['tickTextOffset'][0] x_offset = self._parent.style['tickTextOffset'][0]
path = QtGui.QPainterPath() path = QtWidgets.QPainterPath()
h = self.rect.height() h = self.rect.height()
path.moveTo(0, 0) path.moveTo(0, 0)
path.lineTo(-x_offset - h/4, h/2.) path.lineTo(-x_offset - h/4, h/2.)

View File

@ -19,11 +19,11 @@ High level Qt chart widgets.
""" """
import time import time
from typing import Tuple, Dict, Any, Optional from typing import Tuple, Dict, Any, Optional, List
from types import ModuleType from types import ModuleType
from functools import partial from functools import partial
from PyQt5 import QtCore, QtGui from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtCore import QEvent from PyQt5.QtCore import QEvent
import numpy as np import numpy as np
@ -73,7 +73,7 @@ from ..data import feed
log = get_logger(__name__) log = get_logger(__name__)
class GodWidget(QtGui.QWidget): class GodWidget(QtWidgets.QWidget):
''' '''
"Our lord and savior, the holy child of window-shua, there is no "Our lord and savior, the holy child of window-shua, there is no
widget above thee." - 6|6 widget above thee." - 6|6
@ -92,17 +92,17 @@ class GodWidget(QtGui.QWidget):
super().__init__(parent) super().__init__(parent)
self.hbox = QtGui.QHBoxLayout(self) self.hbox = QtWidgets.QHBoxLayout(self)
self.hbox.setContentsMargins(0, 0, 0, 0) self.hbox.setContentsMargins(0, 0, 0, 0)
self.hbox.setSpacing(2) self.hbox.setSpacing(2)
self.vbox = QtGui.QVBoxLayout() self.vbox = QtWidgets.QVBoxLayout()
self.vbox.setContentsMargins(0, 0, 0, 0) self.vbox.setContentsMargins(0, 0, 0, 0)
self.vbox.setSpacing(2) self.vbox.setSpacing(2)
self.hbox.addLayout(self.vbox) self.hbox.addLayout(self.vbox)
# self.toolbar_layout = QtGui.QHBoxLayout() # self.toolbar_layout = QtWidgets.QHBoxLayout()
# self.toolbar_layout.setContentsMargins(0, 0, 0, 0) # self.toolbar_layout.setContentsMargins(0, 0, 0, 0)
# self.vbox.addLayout(self.toolbar_layout) # self.vbox.addLayout(self.toolbar_layout)
@ -134,7 +134,7 @@ class GodWidget(QtGui.QWidget):
return self._chart_cache.get(symbol_key) return self._chart_cache.get(symbol_key)
# def init_timeframes_ui(self): # def init_timeframes_ui(self):
# self.tf_layout = QtGui.QHBoxLayout() # self.tf_layout = QtWidgets.QHBoxLayout()
# self.tf_layout.setSpacing(0) # self.tf_layout.setSpacing(0)
# self.tf_layout.setContentsMargins(0, 12, 0, 0) # self.tf_layout.setContentsMargins(0, 12, 0, 0)
# time_frames = ('1M', '5M', '15M', '30M', '1H', '1D', '1W', 'MN') # time_frames = ('1M', '5M', '15M', '30M', '1H', '1D', '1W', 'MN')
@ -142,7 +142,7 @@ class GodWidget(QtGui.QWidget):
# for tf in time_frames: # for tf in time_frames:
# btn_name = ''.join([btn_prefix, tf]) # btn_name = ''.join([btn_prefix, tf])
# btn = QtGui.QPushButton(tf) # btn = QtWidgets.QPushButton(tf)
# # TODO: # # TODO:
# btn.setEnabled(False) # btn.setEnabled(False)
# setattr(self, btn_name, btn) # setattr(self, btn_name, btn)
@ -233,7 +233,7 @@ class GodWidget(QtGui.QWidget):
return order_mode_started return order_mode_started
class LinkedSplits(QtGui.QWidget): class LinkedSplits(QtWidgets.QWidget):
''' '''
Widget that holds a central chart plus derived Widget that holds a central chart plus derived
subcharts computed from the original data set apart subcharts computed from the original data set apart
@ -279,11 +279,11 @@ class LinkedSplits(QtGui.QWidget):
# self.xaxis_ind.setStyle(showValues=False) # self.xaxis_ind.setStyle(showValues=False)
# self.xaxis.hide() # self.xaxis.hide()
self.splitter = QtGui.QSplitter(QtCore.Qt.Vertical) self.splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
self.splitter.setMidLineWidth(2) self.splitter.setMidLineWidth(2)
self.splitter.setHandleWidth(0) self.splitter.setHandleWidth(0)
self.layout = QtGui.QVBoxLayout(self) self.layout = QtWidgets.QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.splitter) self.layout.addWidget(self.splitter)
@ -344,7 +344,7 @@ class LinkedSplits(QtGui.QWidget):
self.chart.hideAxis('bottom') self.chart.hideAxis('bottom')
# style? # style?
self.chart.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain) self.chart.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Plain)
return self.chart return self.chart
@ -402,7 +402,7 @@ class LinkedSplits(QtGui.QWidget):
cv.chart = cpw cv.chart = cpw
cpw.plotItem.vb.linkedsplits = self cpw.plotItem.vb.linkedsplits = self
cpw.setFrameStyle(QtGui.QFrame.StyledPanel) # | QtGui.QFrame.Plain) cpw.setFrameStyle(QtWidgets.QFrame.StyledPanel) # | QtWidgets.QFrame.Plain)
cpw.hideButtons() cpw.hideButtons()
# XXX: gives us outline on backside of y-axis # XXX: gives us outline on backside of y-axis
cpw.getPlotItem().setContentsMargins(*CHART_MARGINS) cpw.getPlotItem().setContentsMargins(*CHART_MARGINS)
@ -452,8 +452,8 @@ class ChartPlotWidget(pg.PlotWidget):
eventually want multiple plots managed together?) eventually want multiple plots managed together?)
''' '''
sig_mouse_leave = QtCore.Signal(object) sig_mouse_leave = QtCore.pyqtSignal(object)
sig_mouse_enter = QtCore.Signal(object) sig_mouse_enter = QtCore.pyqtSignal(object)
_l1_labels: L1Labels = None _l1_labels: L1Labels = None
@ -690,11 +690,11 @@ class ChartPlotWidget(pg.PlotWidget):
# https://stackoverflow.com/a/39410081 # https://stackoverflow.com/a/39410081
# seems to only be useful if we don't re-generate the entire # seems to only be useful if we don't re-generate the entire
# QPainterPath every time # QPainterPath every time
# curve.curve.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) # curve.curve.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
# don't ever use this - it's a colossal nightmare of artefacts # don't ever use this - it's a colossal nightmare of artefacts
# and is disastrous for performance. # and is disastrous for performance.
# curve.setCacheMode(QtGui.QGraphicsItem.ItemCoordinateCache) # curve.setCacheMode(QtWidgets.QGraphicsItem.ItemCoordinateCache)
self.addItem(curve) self.addItem(curve)
@ -1702,7 +1702,7 @@ async def _async_main(
def _main( def _main(
sym: str, sym: str,
brokernames: [str], brokernames: List[str],
piker_loglevel: str, piker_loglevel: str,
tractor_kwargs, tractor_kwargs,
) -> None: ) -> None:

View File

@ -23,7 +23,7 @@ from typing import Callable
from PyQt5 import QtCore from PyQt5 import QtCore
from PyQt5.QtCore import QEvent from PyQt5.QtCore import QEvent
from PyQt5.QtGui import QWidget from PyQt5.QtWidgets import QWidget
import trio import trio

View File

@ -24,7 +24,7 @@ from typing import Optional, Callable
import inspect import inspect
import numpy as np import numpy as np
import pyqtgraph as pg import pyqtgraph as pg
from PyQt5 import QtCore, QtGui from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QPointF, QRectF from PyQt5.QtCore import QPointF, QRectF
from .._style import ( from .._style import (
@ -74,7 +74,7 @@ class LineDot(pg.CurvePoint):
brush = pg.mkBrush(cdefault) brush = pg.mkBrush(cdefault)
# presuming this is fast since it's built in? # presuming this is fast since it's built in?
dot = self.dot = QtGui.QGraphicsEllipseItem( dot = self.dot = QtWidgets.QGraphicsEllipseItem(
QtCore.QRectF(-size / 2, -size / 2, size, size) QtCore.QRectF(-size / 2, -size / 2, size, size)
) )
# if we needed transformable dot? # if we needed transformable dot?
@ -358,10 +358,10 @@ class Cursor(pg.GraphicsObject):
# vertical and horizonal lines and a y-axis label # vertical and horizonal lines and a y-axis label
vl = plot.addLine(x=0, pen=self.lines_pen, movable=False) vl = plot.addLine(x=0, pen=self.lines_pen, movable=False)
vl.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) vl.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
hl = plot.addLine(y=0, pen=self.lines_pen, movable=False) hl = plot.addLine(y=0, pen=self.lines_pen, movable=False)
hl.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) hl.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
hl.hide() hl.hide()
yl = YAxisLabel( yl = YAxisLabel(

View File

@ -42,7 +42,7 @@ class FastAppendCurve(pg.PlotCurveItem):
# interactions slower (such as zooming) and if so maybe if/when # interactions slower (such as zooming) and if so maybe if/when
# we implement a "history" mode for the view we disable this in # we implement a "history" mode for the view we disable this in
# that mode? # that mode?
self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
def update_from_array( def update_from_array(
self, self,

View File

@ -435,7 +435,7 @@ class LevelLine(pg.InfiniteLine):
def add_marker( def add_marker(
self, self,
path: QtGui.QGraphicsPathItem, path: QtWidgets.QGraphicsPathItem,
) -> None: ) -> None:
# chart = self._chart # chart = self._chart
@ -527,7 +527,7 @@ class LevelLine(pg.InfiniteLine):
def level_line( def level_line(
chart: 'ChartPlogWidget', # noqa chart: 'ChartPlotWidget', # noqa
level: float, level: float,
color: str = 'default', color: str = 'default',

View File

@ -22,6 +22,7 @@ from typing import List, Optional, Tuple
import numpy as np import numpy as np
import pyqtgraph as pg import pyqtgraph as pg
from numba import njit, float64, int64 # , optional from numba import njit, float64, int64 # , optional
import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QLineF, QPointF from PyQt5.QtCore import QLineF, QPointF
# from numba import types as ntypes # from numba import types as ntypes
@ -172,7 +173,7 @@ def gen_qpath(
class BarItems(pg.GraphicsObject): class BarItems(pg.GraphicsObject):
"""Price range bars graphics rendered from a OHLC sequence. """Price range bars graphics rendered from a OHLC sequence.
""" """
sigPlotChanged = QtCore.Signal(object) sigPlotChanged = QtCore.pyqtSignal(object)
# 0.5 is no overlap between arms, 1.0 is full overlap # 0.5 is no overlap between arms, 1.0 is full overlap
w: float = 0.43 w: float = 0.43
@ -196,7 +197,7 @@ class BarItems(pg.GraphicsObject):
# interactions slower (such as zooming) and if so maybe if/when # interactions slower (such as zooming) and if so maybe if/when
# we implement a "history" mode for the view we disable this in # we implement a "history" mode for the view we disable this in
# that mode? # that mode?
self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
# not sure if this is actually impoving anything but figured it # not sure if this is actually impoving anything but figured it
# was worth a shot: # was worth a shot:

View File

@ -22,7 +22,7 @@ from inspect import isfunction
from typing import Callable from typing import Callable
import pyqtgraph as pg import pyqtgraph as pg
from PyQt5 import QtGui from PyQt5 import QtGui, QtWidgets
from PyQt5.QtCore import QPointF, QRectF from PyQt5.QtCore import QPointF, QRectF
from ._style import ( from ._style import (
@ -105,6 +105,7 @@ class Label:
production grade UIs... production grade UIs...
""" """
def __init__( def __init__(
self, self,
@ -125,7 +126,7 @@ class Label:
self._x_offset = x_offset self._x_offset = x_offset
txt = self.txt = QtGui.QGraphicsTextItem() txt = self.txt = QtWidgets.QGraphicsTextItem()
vb.scene().addItem(txt) vb.scene().addItem(txt)
# configure font size based on DPI # configure font size based on DPI
@ -149,7 +150,7 @@ class Label:
self._anchor_func = self.txt.pos().x self._anchor_func = self.txt.pos().x
# not sure if this makes a diff # not sure if this makes a diff
self.txt.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.txt.setCacheMode(QtWidgets.QGraphicsItem.DeviceCoordinateCache)
# TODO: edit and selection support # TODO: edit and selection support
# https://doc.qt.io/qt-5/qt.html#TextInteractionFlag-enum # https://doc.qt.io/qt-5/qt.html#TextInteractionFlag-enum

View File

@ -511,17 +511,17 @@ class SearchWidget(QtWidgets.QWidget):
self.godwidget = godwidget self.godwidget = godwidget
self.vbox = QtGui.QVBoxLayout(self) self.vbox = QtWidgets.QVBoxLayout(self)
self.vbox.setContentsMargins(0, 0, 0, 0) self.vbox.setContentsMargins(0, 0, 0, 0)
self.vbox.setSpacing(4) self.vbox.setSpacing(4)
# split layout for the (label:| search bar entry) # split layout for the (label:| search bar entry)
self.bar_hbox = QtGui.QHBoxLayout() self.bar_hbox = QtWidgets.QHBoxLayout()
self.bar_hbox.setContentsMargins(0, 0, 0, 0) self.bar_hbox.setContentsMargins(0, 0, 0, 0)
self.bar_hbox.setSpacing(4) self.bar_hbox.setSpacing(4)
# add label to left of search bar # add label to left of search bar
self.label = label = QtGui.QLabel(parent=self) self.label = label = QtWidgets.QLabel(parent=self)
label.setTextFormat(3) # markdown label.setTextFormat(3) # markdown
label.setFont(_font.font) label.setFont(_font.font)
label.setMargin(4) label.setMargin(4)
@ -653,7 +653,7 @@ async def pack_matches(
view: CompleterView, view: CompleterView,
has_results: dict[str, set[str]], has_results: dict[str, set[str]],
matches: dict[(str, str), [str]], matches: dict[(str, str), List[str]],
provider: str, provider: str,
pattern: str, pattern: str,
search: Callable[..., Awaitable[dict]], search: Callable[..., Awaitable[dict]],

View File

@ -25,8 +25,8 @@ from typing import Callable, Optional, Union
import uuid import uuid
from pyqtgraph import QtGui from pyqtgraph import QtGui
from PyQt5 import QtCore from PyQt5 import QtCore, QtWidgets
from PyQt5.QtGui import QLabel, QStatusBar from PyQt5.QtWidgets import QLabel, QStatusBar
from ..log import get_logger from ..log import get_logger
from ._style import _font_small, hcolor from ._style import _font_small, hcolor