Skip to content

Commit

Permalink
move menu bar creation in roi mask to separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Jul 5, 2024
1 parent 6cfb077 commit 4bab6f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
55 changes: 29 additions & 26 deletions package/PartSeg/_roi_analysis/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,35 +577,11 @@ def __init__( # noqa: PLR0915
elif initial_image is not False:
self.settings.image = initial_image

self._setup_menu_bar()

icon = QIcon(os.path.join(PartSegData.icons_dir, "icon.png"))
self.setWindowIcon(icon)

menu_bar = self.menuBar()
file_menu = menu_bar.addMenu("File")
file_menu.addAction("&Open").triggered.connect(self.main_menu.load_data)
file_menu.addMenu(self.recent_file_menu)
file_menu.addAction("&Save").triggered.connect(self.main_menu.save_file)
file_menu.addAction("Batch processing").triggered.connect(self.main_menu.batch_window)
view_menu = menu_bar.addMenu("View")
view_menu.addAction("Settings and Measurement").triggered.connect(self.main_menu.advanced_window_show)
view_menu.addAction("Additional output").triggered.connect(self.additional_layers_show)
view_menu.addAction("Additional output with data").triggered.connect(lambda: self.additional_layers_show(True))
view_menu.addAction("Napari viewer").triggered.connect(self.napari_viewer_show)
view_menu.addAction("Toggle Multiple Files").triggered.connect(self.toggle_multiple_files)
view_menu.addAction("Toggle left panel").triggered.connect(self.toggle_left_panel)
view_menu.addAction("Toggle console").triggered.connect(self._toggle_console)
view_menu.addAction("Toggle scale bar").triggered.connect(self._toggle_scale_bar)
action = view_menu.addAction("Screenshot right panel")
action.triggered.connect(self.screenshot(self.result_image))
action.setShortcut(QKeySequence.Print)
view_menu.addAction("Screenshot left panel").triggered.connect(self.screenshot(self.raw_image))
image_menu = menu_bar.addMenu("Image operations")
image_menu.addAction("Image adjustment").triggered.connect(self.image_adjust_exec)
image_menu.addAction("Mask manager").triggered.connect(self.main_menu.mask_manager)
help_menu = menu_bar.addMenu("Help")
help_menu.addAction("State directory").triggered.connect(self.show_settings_directory)
help_menu.addAction("About").triggered.connect(self.show_about_dialog)

layout = QGridLayout()
layout.setSpacing(0)
info_layout = QHBoxLayout()
Expand All @@ -632,6 +608,33 @@ def __init__( # noqa: PLR0915
geometry = self.settings.get_from_profile("main_window_geometry")
self.restoreGeometry(QByteArray.fromHex(bytes(geometry, "ascii")))

def _setup_menu_bar(self):
menu_bar = self.menuBar()
file_menu = menu_bar.addMenu("File")
file_menu.addAction("&Open").triggered.connect(self.main_menu.load_data)
file_menu.addMenu(self.recent_file_menu)
file_menu.addAction("&Save").triggered.connect(self.main_menu.save_file)
file_menu.addAction("Batch processing").triggered.connect(self.main_menu.batch_window)
view_menu = menu_bar.addMenu("View")
view_menu.addAction("Settings and Measurement").triggered.connect(self.main_menu.advanced_window_show)
view_menu.addAction("Additional output").triggered.connect(self.additional_layers_show)
view_menu.addAction("Additional output with data").triggered.connect(lambda: self.additional_layers_show(True))
view_menu.addAction("Napari viewer").triggered.connect(self.napari_viewer_show)
view_menu.addAction("Toggle Multiple Files").triggered.connect(self.toggle_multiple_files)
view_menu.addAction("Toggle left panel").triggered.connect(self.toggle_left_panel)
view_menu.addAction("Toggle console").triggered.connect(self._toggle_console)
view_menu.addAction("Toggle scale bar").triggered.connect(self._toggle_scale_bar)
action = view_menu.addAction("Screenshot right panel")
action.triggered.connect(self.screenshot(self.result_image))
action.setShortcut(QKeySequence.Print)
view_menu.addAction("Screenshot left panel").triggered.connect(self.screenshot(self.raw_image))
image_menu = menu_bar.addMenu("Image operations")
image_menu.addAction("Image adjustment").triggered.connect(self.image_adjust_exec)
image_menu.addAction("Mask manager").triggered.connect(self.main_menu.mask_manager)
help_menu = menu_bar.addMenu("Help")
help_menu.addAction("State directory").triggered.connect(self.show_settings_directory)
help_menu.addAction("About").triggered.connect(self.show_about_dialog)

def _toggle_scale_bar(self):
self.raw_image.toggle_scale_bar()
self.result_image.toggle_scale_bar()
Expand Down
4 changes: 2 additions & 2 deletions package/PartSeg/_roi_mask/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def __init__(
icon = QIcon(os.path.join(PartSegData.icons_dir, "icon_stack.png"))
self.setWindowIcon(icon)

self._setup_menu()
self._setup_menu_bar()

layout = QVBoxLayout()
layout.addWidget(self.main_menu)
Expand Down Expand Up @@ -947,7 +947,7 @@ def __init__(
geometry = self.settings.get_from_profile("main_window_geometry")
self.restoreGeometry(QByteArray.fromHex(bytes(geometry, "ascii")))

def _setup_menu(self):
def _setup_menu_bar(self):
menu_bar = self.menuBar()
file_menu = menu_bar.addMenu("File")
file_menu.addAction("&Open").triggered.connect(self.main_menu.load_image)
Expand Down

0 comments on commit 4bab6f6

Please sign in to comment.