diff --git a/__init__.py b/__init__.py index cb259db..941c932 100644 --- a/__init__.py +++ b/__init__.py @@ -1,31 +1,33 @@ # Shim for submodule usage in Squid # Re-exports from the nested ndviewer_light package -from .ndviewer_light import ( - __version__, - FPATTERN, - FPATTERN_OME, - MAX_3D_TEXTURE_SIZE, - LightweightMainWindow, - LightweightViewer, - data_structure_changed, - detect_format, - extract_ome_physical_sizes, - read_acquisition_parameters, - read_tiff_pixel_size, - wavelength_to_colormap, -) +# Only imports when used as a submodule (has parent package) +if __package__: + from .ndviewer_light import ( + __version__, + FPATTERN, + FPATTERN_OME, + MAX_3D_TEXTURE_SIZE, + LightweightMainWindow, + LightweightViewer, + data_structure_changed, + detect_format, + extract_ome_physical_sizes, + read_acquisition_parameters, + read_tiff_pixel_size, + wavelength_to_colormap, + ) -__all__ = [ - "__version__", - "FPATTERN", - "FPATTERN_OME", - "MAX_3D_TEXTURE_SIZE", - "LightweightMainWindow", - "LightweightViewer", - "data_structure_changed", - "detect_format", - "extract_ome_physical_sizes", - "read_acquisition_parameters", - "read_tiff_pixel_size", - "wavelength_to_colormap", -] + __all__ = [ + "__version__", + "FPATTERN", + "FPATTERN_OME", + "MAX_3D_TEXTURE_SIZE", + "LightweightMainWindow", + "LightweightViewer", + "data_structure_changed", + "detect_format", + "extract_ome_physical_sizes", + "read_acquisition_parameters", + "read_tiff_pixel_size", + "wavelength_to_colormap", + ] diff --git a/ndviewer_light/core.py b/ndviewer_light/core.py index aad2e05..0bb076e 100644 --- a/ndviewer_light/core.py +++ b/ndviewer_light/core.py @@ -57,6 +57,17 @@ def _patched_setRange(self, a, b): if hasattr(self, "_slider"): self._slider.setMinimum(a) self._slider.setMaximum(b) + + # Proportional handle sizing based on number of positions + num_positions = b - a + 1 + # Scale handle: larger for fewer positions, smaller for many + # Clamp between 8px (minimum usable) and 40px (maximum reasonable) + handle_width = max(8, min(40, 200 // max(1, num_positions))) + self._slider.setStyleSheet( + f"QSlider::handle:horizontal {{ width: {handle_width}px; }}" + f"QSlider::handle:vertical {{ height: {handle_width}px; }}" + ) + if hasattr(self, "_label"): try: self._label.setRange(a, b) diff --git a/pyproject.toml b/pyproject.toml index ac5e657..6e88bf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,3 +24,9 @@ dependencies = [ [tool.setuptools.packages.find] where = ["."] include = ["ndviewer_light"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = ["test_*.py"] +norecursedirs = ["__pycache__"] +addopts = "--ignore=__init__.py"