From ad571626a78112dd4f8d88ca62968de1c6738527 Mon Sep 17 00:00:00 2001 From: Eric Leonardis Date: Thu, 2 Jan 2025 11:13:48 -0800 Subject: [PATCH] set negatives to 1 --- sleap/gui/widgets/slider.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sleap/gui/widgets/slider.py b/sleap/gui/widgets/slider.py index c35030eaf..e07a6f785 100644 --- a/sleap/gui/widgets/slider.py +++ b/sleap/gui/widgets/slider.py @@ -379,6 +379,9 @@ def _toVal(self, x: float, center=False) -> float: Returns: Slider value (frame index). """ + if x is None: + raise ValueError("x position cannot be None") + val = x val /= self._slider_width val *= max(1, self._val_max - self._val_min) @@ -389,7 +392,10 @@ def _toVal(self, x: float, center=False) -> float: @property def _slider_width(self) -> float: """Returns visual width of slider.""" - return self.box_rect.width() + width = self.box_rect.width() + if width <= 0: + return 1.0 + return width @property def slider_visible_value_range(self) -> float: