From 539851f5a4c90e64866ade7a55dd583e7476a63b Mon Sep 17 00:00:00 2001
From: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com>
Date: Fri, 3 Jan 2025 14:36:02 +0000
Subject: [PATCH] Add scroll bar (#68)
---
.../registration_widget.py | 28 +++++++++++--------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/brainglobe_registration/registration_widget.py b/brainglobe_registration/registration_widget.py
index 131e71d..1d14756 100644
--- a/brainglobe_registration/registration_widget.py
+++ b/brainglobe_registration/registration_widget.py
@@ -26,7 +26,7 @@
from napari.utils.notifications import show_error
from napari.viewer import Viewer
from pytransform3d.rotations import active_matrix_from_angle
-from qtpy.QtWidgets import QCheckBox, QPushButton, QTabWidget
+from qtpy.QtWidgets import QCheckBox, QPushButton, QScrollArea, QTabWidget
from skimage.segmentation import find_boundaries
from skimage.transform import rescale
@@ -51,10 +51,11 @@
)
-class RegistrationWidget(CollapsibleWidgetContainer):
+class RegistrationWidget(QScrollArea):
def __init__(self, napari_viewer: Viewer):
super().__init__()
- self.setContentsMargins(10, 10, 10, 10)
+ self.widget = CollapsibleWidgetContainer()
+ self.widget.setContentsMargins(10, 10, 10, 10)
self._viewer = napari_viewer
self._atlas: Optional[BrainGlobeAtlas] = None
@@ -149,7 +150,7 @@ def __init__(self, napari_viewer: Viewer):
self.run_button.clicked.connect(self._on_run_button_click)
self.run_button.setEnabled(False)
- self.add_widget(
+ self.widget.add_widget(
header_widget(
"brainglobe-
registration", # line break at
"Registration with Elastix",
@@ -157,11 +158,13 @@ def __init__(self, napari_viewer: Viewer):
),
collapsible=False,
)
- self.add_widget(self.get_atlas_widget, widget_title="Select Images")
- self.add_widget(
+ self.widget.add_widget(
+ self.get_atlas_widget, widget_title="Select Images"
+ )
+ self.widget.add_widget(
self.adjust_moving_image_widget, widget_title="Prepare Images"
)
- self.add_widget(
+ self.widget.add_widget(
self.transform_select_view, widget_title="Select Transformations"
)
@@ -177,18 +180,21 @@ def __init__(self, napari_viewer: Viewer):
self.parameters_tab.addTab(new_tab, transform_type)
self.parameter_setting_tabs_lists.append(new_tab)
- self.add_widget(
+ self.widget.add_widget(
self.parameters_tab, widget_title="Advanced Settings (optional)"
)
- self.add_widget(self.filter_checkbox, collapsible=False)
+ self.widget.add_widget(self.filter_checkbox, collapsible=False)
- self.add_widget(self.run_button, collapsible=False)
+ self.widget.add_widget(self.run_button, collapsible=False)
- self.layout().itemAt(1).widget().collapse(animate=False)
+ self.widget.layout().itemAt(1).widget().collapse(animate=False)
check_atlas_installed(self)
+ self.setWidgetResizable(True)
+ self.setWidget(self.widget)
+
def _connect_events(self):
@self._viewer.layers.events.removed.connect
def _on_layer_deleted(event: Event):