Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving experience #131

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions sashimi/gui/camera_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
7 changes: 3 additions & 4 deletions sashimi/gui/main_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down
7 changes: 4 additions & 3 deletions sashimi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sashimi.config import cli_edit_config
from sashimi.state import State
from pathlib import Path
import napari


@click.command()
Expand All @@ -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()
Expand Down
10 changes: 6 additions & 4 deletions tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import qdarkstyle
from PyQt5.QtCore import Qt
from split_dataset import SplitDataset
import napari


class MockEvt:
Expand All @@ -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)

Expand All @@ -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)
Expand Down