Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
11 changes: 11 additions & 0 deletions ndviewer_light/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading