diff --git a/fastplotlib/graphics/selectors/_base_selector.py b/fastplotlib/graphics/selectors/_base_selector.py index a4159c194..fa5f612cf 100644 --- a/fastplotlib/graphics/selectors/_base_selector.py +++ b/fastplotlib/graphics/selectors/_base_selector.py @@ -84,6 +84,8 @@ def __init__( # otherwise annoying and requires too much accuracy to move just an edge self._edge_hovered: bool = False + self._pygfx_event = None + def get_selected_index(self): """Not implemented for this selector""" raise NotImplementedError diff --git a/fastplotlib/graphics/selectors/_linear.py b/fastplotlib/graphics/selectors/_linear.py index 39710305d..935b5d676 100644 --- a/fastplotlib/graphics/selectors/_linear.py +++ b/fastplotlib/graphics/selectors/_linear.py @@ -94,8 +94,8 @@ def __init__( line_data = np.column_stack([xs, ys, zs]) elif axis == "y": - xs = np.zeros(end_points) - ys = np.array(2) + xs = np.array(end_points) + ys = np.zeros(2) zs = np.zeros(2) line_data = np.column_stack([xs, ys, zs]) @@ -150,7 +150,6 @@ def __init__( self._setup_ipywidget_slider(ipywidget_slider) self._move_info: dict = None - self._pygfx_event = None self.parent = parent @@ -278,9 +277,9 @@ def _get_selected_index(self, graphic): or math.fabs(find_value - geo_positions[idx - 1]) < math.fabs(find_value - geo_positions[idx]) ): - return int(idx - 1) + return round(idx - 1) else: - return int(idx) + return round(idx) if ( "Heatmap" in graphic.__class__.__name__ @@ -288,7 +287,7 @@ def _get_selected_index(self, graphic): ): # indices map directly to grid geometry for image data buffer index = self.selection() - offset - return int(index) + return round(index) def _move_graphic(self, delta: np.ndarray): """ diff --git a/fastplotlib/graphics/selectors/_sync.py b/fastplotlib/graphics/selectors/_sync.py index b01823394..499f05449 100644 --- a/fastplotlib/graphics/selectors/_sync.py +++ b/fastplotlib/graphics/selectors/_sync.py @@ -1,8 +1,9 @@ from . import LinearSelector +from typing import * class Synchronizer: - def __init__(self, *selectors: LinearSelector, key_bind: str = "Shift"): + def __init__(self, *selectors: LinearSelector, key_bind: Union[str, None] = "Shift"): """ Synchronize the movement of `Selectors`. Selectors will move in sync only when the selected `"key_bind"` is used during the mouse movement event. Valid key binds are: ``"Control"``, ``"Shift"`` and ``"Alt"``.