Skip to content

Commit 575e976

Browse files
Wrap annotator in a scroll area (#553)
1 parent a79c5b3 commit 575e976

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

micro_sam/sam_annotator/_annotator.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ._state import AnnotatorState
1010

1111

12-
class _AnnotatorBase(QtWidgets.QWidget):
12+
class _AnnotatorBase(QtWidgets.QScrollArea):
1313
"""Base class for micro_sam annotation plugins.
1414
1515
Implements the logic for the 2d, 3d and tracking annotator.
@@ -103,7 +103,8 @@ def __init__(self, viewer: "napari.viewer.Viewer", ndim: int) -> None:
103103
"""
104104
super().__init__()
105105
self._viewer = viewer
106-
self.setLayout(QtWidgets.QVBoxLayout())
106+
self._annotator_widget = QtWidgets.QWidget()
107+
self._annotator_widget.setLayout(QtWidgets.QVBoxLayout())
107108

108109
# Add the layers for prompts and segmented obejcts.
109110
# Initialize with a dummy shape, which is reset to the correct shape once an image is set.
@@ -123,14 +124,18 @@ def __init__(self, viewer: "napari.viewer.Viewer", ndim: int) -> None:
123124
# This is a qt type and we add the widget directly.
124125
widget_layout.addWidget(widget)
125126
widget_frame.setLayout(widget_layout)
126-
self.layout().addWidget(widget_frame)
127+
self._annotator_widget.layout().addWidget(widget_frame)
127128

128129
# Add the widgets to the state.
129130
AnnotatorState().widgets = self._widgets
130131

131132
# Add the key bindings in common between all annotators.
132133
self._create_keybindings()
133134

135+
# Add the widget to the scroll area.
136+
self.setWidgetResizable(True) # Allow widget to resize within scroll area.
137+
self.setWidget(self._annotator_widget)
138+
134139
def _update_image(self, segmentation_result=None):
135140
state = AnnotatorState()
136141

0 commit comments

Comments
 (0)