diff --git a/sashimi/gui/camera_gui.py b/sashimi/gui/camera_gui.py index afab32f5..a348481b 100644 --- a/sashimi/gui/camera_gui.py +++ b/sashimi/gui/camera_gui.py @@ -65,7 +65,7 @@ class ViewingWidget(QWidget): _DELAY_REFRESH_COUNT = 10 - def __init__(self, state: State, timer: QTimer, style: str): + def __init__(self, state: State, timer: QTimer, style: str, viewer: napari.Viewer): super().__init__() self.state = state timer.timeout.connect(self.refresh) @@ -86,7 +86,7 @@ def __init__(self, state: State, timer: QTimer, style: str): s = self.get_fullframe_size() self.image_shape = (1, s, s) - self.viewer = napari.Viewer(show=False) + self.viewer = viewer # setting napari style to sashimi's self.viewer.window.qt_viewer.setStyleSheet(style) diff --git a/sashimi/gui/main_gui.py b/sashimi/gui/main_gui.py index 17aa992e..7c9232c6 100644 --- a/sashimi/gui/main_gui.py +++ b/sashimi/gui/main_gui.py @@ -28,17 +28,15 @@ def __init__(self, widget=None, layout=None, title=""): class MainWindow(QMainWindow): - def __init__(self, st: State, style: str): + def __init__(self, st: State, style: str, viewer): super().__init__() self.st = st self.timer = QTimer() - self.showMaximized() self.wid_settings_tree = SavingSettingsWidget(st) self.wid_settings_tree.sig_params_loaded.connect(self.refresh_param_values) - self.wid_status = StatusWidget(st, self.timer) - self.wid_display = ViewingWidget(st, self.timer, style) + self.wid_display = ViewingWidget(st, self.timer, style, viewer) self.wid_save_options = SaveWidget(st, self.timer) self.wid_laser = LightSourceWidget(st, self.timer) self.wid_scan = PlanarScanningWidget(st) @@ -85,6 +83,7 @@ def __init__(self, st: State, style: str): self.timer.start() self.timer.timeout.connect(self.check_end_experiment) self.setup_menu_bar() + self.showMaximized() self.refresh_param_values() diff --git a/sashimi/main.py b/sashimi/main.py index 700c902a..c65b2958 100644 --- a/sashimi/main.py +++ b/sashimi/main.py @@ -6,6 +6,7 @@ from sashimi.config import cli_edit_config from sashimi.state import State from pathlib import Path +import napari @click.command() @@ -16,13 +17,13 @@ def main(scopeless, scanning, **kwargs): cli_edit_config("scanning", scanning) # TODO configure logging with CLI - app = QApplication([]) + viewer = napari.Viewer(show=False) style = qdarkstyle.load_stylesheet_pyqt5() app.setStyleSheet(style) app.setApplicationName("Sashimi") - st = State() - main_window = MainWindow(st, style) + state = State() + main_window = MainWindow(state, style, viewer) icon_dir = (Path(__file__).parents[0]).resolve() / "icons/main_icon.png" app.setWindowIcon(QIcon(str(icon_dir))) # PyQt does not accept Path main_window.show() diff --git a/tests/test_gui.py b/tests/test_gui.py index 981536be..a79886ff 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -3,6 +3,7 @@ import qdarkstyle from PyQt5.QtCore import Qt from split_dataset import SplitDataset +import napari class MockEvt: @@ -11,9 +12,10 @@ def accept(self): def test_main(qtbot, temp_path): - st = State() + viewer = napari.Viewer(show=False) + state = State() style = qdarkstyle.load_stylesheet_pyqt5() - main_window = MainWindow(st, style) + main_window = MainWindow(state, style, viewer) main_window.show() qtbot.wait(300) @@ -23,9 +25,9 @@ def test_main(qtbot, temp_path): main_window.wid_status.setCurrentIndex(3) # Manually update new directory (to avoid nasty pop up window for filesystem): - st.save_settings.save_dir = str(temp_path) + state.save_settings.save_dir = str(temp_path) main_window.wid_save_options.set_locationbutton() - st.send_scansave_settings() + state.send_scansave_settings() # Wait to send and receive parameters: qtbot.wait(10000)