Use (modern) literal type annots in view code
parent
29f4b562bd
commit
c8c5a234e8
|
@ -21,7 +21,11 @@ Chart view box primitives
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
import time
|
import time
|
||||||
from typing import Optional, Callable
|
from typing import (
|
||||||
|
Optional,
|
||||||
|
Callable,
|
||||||
|
TYPE_CHECKING,
|
||||||
|
)
|
||||||
|
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
# from pyqtgraph.GraphicsScene import mouseEvents
|
# from pyqtgraph.GraphicsScene import mouseEvents
|
||||||
|
@ -39,6 +43,9 @@ from .._profile import pg_profile_enabled, ms_slower_then
|
||||||
from ._editors import SelectRect
|
from ._editors import SelectRect
|
||||||
from . import _event
|
from . import _event
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ._chart import ChartPlotWidget
|
||||||
|
|
||||||
|
|
||||||
log = get_logger(__name__)
|
log = get_logger(__name__)
|
||||||
|
|
||||||
|
@ -374,7 +381,7 @@ class ChartView(ViewBox):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.linked = None
|
self.linked = None
|
||||||
self._chart: 'ChartPlotWidget' = None # noqa
|
self._chart: ChartPlotWidget | None = None # noqa
|
||||||
|
|
||||||
# add our selection box annotator
|
# add our selection box annotator
|
||||||
self.select_box = SelectRect(self)
|
self.select_box = SelectRect(self)
|
||||||
|
@ -445,11 +452,11 @@ class ChartView(ViewBox):
|
||||||
yield self
|
yield self
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def chart(self) -> 'ChartPlotWidget': # type: ignore # noqa
|
def chart(self) -> ChartPlotWidget: # type: ignore # noqa
|
||||||
return self._chart
|
return self._chart
|
||||||
|
|
||||||
@chart.setter
|
@chart.setter
|
||||||
def chart(self, chart: 'ChartPlotWidget') -> None: # type: ignore # noqa
|
def chart(self, chart: ChartPlotWidget) -> None: # type: ignore # noqa
|
||||||
self._chart = chart
|
self._chart = chart
|
||||||
self.select_box.chart = chart
|
self.select_box.chart = chart
|
||||||
if self._maxmin is None:
|
if self._maxmin is None:
|
||||||
|
@ -783,11 +790,9 @@ class ChartView(ViewBox):
|
||||||
|
|
||||||
if yrange is None:
|
if yrange is None:
|
||||||
log.warning(f'No yrange provided for {name}!?')
|
log.warning(f'No yrange provided for {name}!?')
|
||||||
print(f"WTF NO YRANGE {name}")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
ylow, yhigh = yrange
|
ylow, yhigh = yrange
|
||||||
|
|
||||||
profiler(f'callback ._maxmin(): {yrange}')
|
profiler(f'callback ._maxmin(): {yrange}')
|
||||||
|
|
||||||
# view margins: stay within a % of the "true range"
|
# view margins: stay within a % of the "true range"
|
||||||
|
|
Loading…
Reference in New Issue