diff --git a/copylot/gui/_qt/dockables/live_control.py b/copylot/gui/_qt/dockables/live_control.py index 25ddd301..f332289d 100644 --- a/copylot/gui/_qt/dockables/live_control.py +++ b/copylot/gui/_qt/dockables/live_control.py @@ -31,16 +31,14 @@ def __init__(self, parent, threadpool): # view and channel combobox widgets and options self.view_combobox = QComboBox() - self.view_combobox.addItem("view 1") - self.view_combobox.addItem("view 2") + self.view_combobox.addItems(["view 1", "view 2"]) self.view_combobox.setCurrentIndex(self.parent.defaults["live"]["view"]) self.layout.addWidget(self.view_combobox) self.view_combobox.activated.connect(self.launch_nidaq) self.laser_combobox = QComboBox() - self.laser_combobox.addItem("488") - self.laser_combobox.addItem("561") + self.laser_combobox.addItems(["488", "561"]) self.laser_combobox.setCurrentIndex(self.parent.defaults["live"]["laser"]) self.layout.addWidget(self.laser_combobox) diff --git a/copylot/gui/_qt/dockables/live_timelapse.py b/copylot/gui/_qt/dockables/live_timelapse.py new file mode 100644 index 00000000..fc81c57f --- /dev/null +++ b/copylot/gui/_qt/dockables/live_timelapse.py @@ -0,0 +1,48 @@ +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton + +from copylot.hardware.ni_daq.nidaq import NIDaq + + +class LiveTimelapseDockWidget(QWidget): + def __init__(self, parent, threadpool): + super(QWidget, self).__init__(parent) + + self.parent = parent + self.threadpool = threadpool + + self.running = False + self.wait_before_shutdown = False + + self.layout = QVBoxLayout() + self.layout.setAlignment(Qt.AlignTop) + + # add instance launching button + self.live_button = QPushButton("Live Button") + self.timelapse_button = QPushButton("Timelapse Button") + + self.layout.addWidget(self.live_button) + self.layout.addWidget(self.timelapse_button) + + self.setLayout(self.layout) + + def timelapse_worker_method(self): + view = self.view_combobox.currentIndex() + channel = ( + [int(self.laser_combobox.currentText())] + if self.laser_combobox.currentIndex() != 2 + else [488, 561] + ) + parameters = self.parent.parameters_widget.parameters + + daq_card = NIDaq(self, **parameters) + daq_card.acquire_stacks(channels=channel, view=view) + + def live_worker_method(self): + view = self.combobox_view + channel = self.combobox_channel + parameters = self.parent.parameters_widget.parameters + + daq_card = NIDaq(self, **parameters) + daq_card.select_view(view) + daq_card.select_channel_remove_stripes(channel) diff --git a/copylot/gui/_qt/dockables/timelapse_control.py b/copylot/gui/_qt/dockables/timelapse_control.py index 6b75760c..b94e2339 100644 --- a/copylot/gui/_qt/dockables/timelapse_control.py +++ b/copylot/gui/_qt/dockables/timelapse_control.py @@ -37,17 +37,13 @@ def __init__(self, parent, threadpool): # view and channel combobox widgets and options self.view_combobox = QComboBox() - self.view_combobox.addItem("view 1") - self.view_combobox.addItem("view 2") - self.view_combobox.addItem("view 1 and 2") + self.view_combobox.addItems(["view 1", "view 2", "view 1 and 2"]) self.view_combobox.setCurrentIndex(self.parent.defaults["timelapse"]["view"]) self.layout.addWidget(self.view_combobox) self.laser_combobox = QComboBox() - self.laser_combobox.addItem("488") - self.laser_combobox.addItem("561") - self.laser_combobox.addItem("488 and 561") + self.laser_combobox.addItems(["488", "561", "488 and 561"]) self.laser_combobox.setCurrentIndex(self.parent.defaults["timelapse"]["laser"]) self.layout.addWidget(self.laser_combobox) diff --git a/copylot/gui/gui.py b/copylot/gui/gui.py index 08757024..1a9b0137 100644 --- a/copylot/gui/gui.py +++ b/copylot/gui/gui.py @@ -91,10 +91,8 @@ def __init__(self, *args, **kwargs): json.dump(self.defaults, outfile) # initialize docks - self.live_dock = QDockWidget(self) - self.live_dock.setTitleBarWidget(QLabel("Live Mode")) - self.timelapse_dock = QDockWidget(self) - self.timelapse_dock.setTitleBarWidget(QLabel("Timelapse Mode")) + self.livetimelapse_dock = QDockWidget(self) + self.livetimelapse_dock.setTitleBarWidget(QLabel("Live/Timelapse Mode")) self.water_dock = QDockWidget(self) self.water_dock.setTitleBarWidget(QLabel("Water Dispenser")) self.parameters_dock = QDockWidget(self) @@ -102,8 +100,7 @@ def __init__(self, *args, **kwargs): # set common configurations for docks self.dock_list = [ - self.live_dock, - self.timelapse_dock, + self.livetimelapse_dock, self.water_dock, self.parameters_dock, ] @@ -111,20 +108,12 @@ def __init__(self, *args, **kwargs): _apply_dock_config(dock) # initialize widgets and assign to their dock - self.live_dock.setWidget( + self.livetimelapse_dock.setWidget( DockPlaceholder( - self, self.live_dock, "live_control", [self, self.threadpool] + self, self.livetimelapse_dock, "live_timelapse", [self, self.threadpool] ) ) # self.addDockWidget(Qt.RightDockWidgetArea, self.live_dock) - # - # self.timelapse_widget = TimelapseControl(self, self.threadpool) - self.timelapse_dock.setWidget( - DockPlaceholder( - self, self.timelapse_dock, "timelapse_control", [self, self.threadpool] - ) - ) - # self.addDockWidget(Qt.RightDockWidgetArea, self.timelapse_dock) # self.water_widget = WaterDispenser(self, self.threadpool) self.water_dock.setWidget( @@ -142,9 +131,10 @@ def __init__(self, *args, **kwargs): self.addDockWidget(Qt.LeftDockWidgetArea, self.parameters_dock) # split horizontal and vertical space between docks - self.splitDockWidget(self.parameters_dock, self.live_dock, Qt.Horizontal) - self.splitDockWidget(self.live_dock, self.timelapse_dock, Qt.Vertical) - self.splitDockWidget(self.timelapse_dock, self.water_dock, Qt.Vertical) + self.splitDockWidget( + self.parameters_dock, self.livetimelapse_dock, Qt.Horizontal + ) + self.splitDockWidget(self.livetimelapse_dock, self.water_dock, Qt.Vertical) # create status bar that is updated from live and timelapse control classes self.status_bar = QStatusBar()