Skip to content
Closed
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
18 changes: 11 additions & 7 deletions src/navigate/controller/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
class Configurator:
"""Navigate Configurator"""

def __init__(self, root, splash_screen):
def __init__(self, root: tk.Tk, splash_screen):
"""Initiates the configurator application window.

Parameters
Expand Down Expand Up @@ -186,11 +186,12 @@ def set_value(temp_dict, key_list, value):
if k.strip() == "":
warning_info[hardware_name] = True
print(
f"Notice: {hardware_name} has an empty value {ref}! Please double check if it's okay!"
f"Notice: {hardware_name} has an empty value "
f"{ref}! Please double check if it's okay!"
)

if k_idx in value_dict:
k = value_dict[k_idx][v]
k = value_dict[k_idx][v] # noqa
v = variables[v_idx].get()
if v_idx in value_dict:
v = value_dict[v_idx][v]
Expand All @@ -208,7 +209,8 @@ def set_value(temp_dict, key_list, value):
except tk._tkinter.TclError:
v = ""
print(
f"Notice: {hardware_name} has an empty value {k}! Please double check!"
f"Notice: {hardware_name} has an empty value {k}! "
f"Please double check!"
)
warning_info[hardware_name] = True
set_value(temp_dict, k.split("/"), v)
Expand All @@ -218,7 +220,9 @@ def set_value(temp_dict, key_list, value):
if warning_info:
messagebox.showwarning(
title="Configuration",
message=f"There are empty value(s) with {', '.join(warning_info.keys())}. Please double check!",
message=f"There are empty value(s) with "
f"{', '.join(warning_info.keys())}"
f". Please double check!",
)

def write_to_yaml(self, config, filename):
Expand Down Expand Up @@ -404,7 +408,7 @@ def build_widgets_value(widgets, value_dict):
hardware_ref_name
],
)
except Exception as e:
except Exception:
widgets_value = [None]
microscope_tab.create_hardware_tab(
hardware_type, widgets, hardware_widgets_value=widgets_value
Expand All @@ -425,7 +429,7 @@ def build_widgets_value(widgets, value_dict):
],
),
]
except:
except Exception:
widgets_value = [[None], [None]]
microscope_tab.create_hardware_tab(
hardware_type,
Expand Down
45 changes: 32 additions & 13 deletions src/navigate/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import os
import time
import platform
import reprlib

# Third Party Imports

Expand All @@ -64,6 +63,7 @@
FeaturePopupController,
MenuController,
PluginsController,
HistogramController,
# MicroscopePopupController,
# AdaptiveOpticsPopupController,
)
Expand Down Expand Up @@ -97,6 +97,7 @@

class Controller:
"""Navigate Controller"""

def __init__(
self,
root,
Expand Down Expand Up @@ -198,8 +199,10 @@ def __init__(
verify_waveform_constants(self.manager, self.configuration)

total_ram, available_ram = get_ram_info()
logger.info(f"Total RAM: {total_ram / 1024**3:.2f} GB. "
f"Available RAM: {available_ram / 1024**3:.2f} GB.")
logger.info(
f"Total RAM: {total_ram / 1024**3:.2f} GB. "
f"Available RAM: {available_ram / 1024**3:.2f} GB."
)

#: ObjectInSubprocess: Model object in MVC architecture.
self.model = ObjectInSubprocess(
Expand All @@ -225,7 +228,7 @@ def __init__(
self.event_listeners = {}

#: AcquireBarController: Acquire Bar Sub-Controller.
self.acquire_bar_controller = AcquireBarController(self.view.acqbar, self)
self.acquire_bar_controller = AcquireBarController(self.view.acquire_bar, self)

#: ChannelsTabController: Channels Tab Sub-Controller.
self.channels_tab_controller = ChannelsTabController(
Expand All @@ -242,6 +245,11 @@ def __init__(
self.view.camera_waveform.camera_tab, self
)

#: HistogramController: Histogram Tab Sub-Controller.
self.histogram_controller = HistogramController(
self.view.misc.histogram_tab, self
)

#: MIPSettingController: MIP Settings Tab Sub-Controller.
self.mip_setting_controller = MIPViewController(
self.view.camera_waveform.mip_tab, self
Expand Down Expand Up @@ -365,7 +373,7 @@ def update_buffer(self):

def update_acquire_control(self):
"""Update the acquire control based on the current experiment parameters."""
self.view.acqbar.stop_stage.config(
self.view.acquire_bar.stop_stage.config(
command=self.stage_controller.stop_button_handler
)

Expand Down Expand Up @@ -551,12 +559,14 @@ def refresh(width, height):
height : int
Height of the GUI.
"""
if width < 1200 or height < 600:
if width < 1300 or height < 800:
return
self.view.camera_waveform["width"] = (
width - self.view.frame_left.winfo_width() - 81
)
self.view.camera_waveform["height"] = height - 110
width - self.view.left_frame.winfo_width() - 35
) #
self.view.camera_waveform["height"] = height - 117

print("camera_waveform height", self.view.camera_waveform["height"])

if event.widget != self.view.scroll_frame:
return
Expand Down Expand Up @@ -1081,13 +1091,16 @@ def capture_image(self, command, mode, *args):
)
self.execute("stop_acquire")

# Display the Image in the View
# Display the image and update the histogram
self.camera_view_controller.try_to_display_image(
image=self.data_buffer[image_id]
)
self.mip_setting_controller.try_to_display_image(
image=self.data_buffer[image_id]
)
self.histogram_controller.populate_histogram(
image=self.data_buffer[image_id]
)
images_received += 1

# Update progress bar.
Expand Down Expand Up @@ -1212,7 +1225,9 @@ def display_images(
)
camera_view_controller.microscope_name = microscope_name
popup_window.popup.bind("<Configure>", camera_view_controller.resize)
self.additional_microscopes[microscope_name]["popup_window"] = popup_window
self.additional_microscopes[microscope_name][
"popup_window"
] = popup_window
self.additional_microscopes[microscope_name][
"camera_view_controller"
] = camera_view_controller
Expand All @@ -1226,7 +1241,9 @@ def display_images(
),
)

self.additional_microscopes[microscope_name]["show_img_pipe"] = show_img_pipe
self.additional_microscopes[microscope_name][
"show_img_pipe"
] = show_img_pipe
self.additional_microscopes[microscope_name]["data_buffer"] = data_buffer

# start thread
Expand Down Expand Up @@ -1263,7 +1280,9 @@ def destroy_virtual_microscope(self, microscope_name, destroy_window=True):
# destroy the popup window
if destroy_window:
self.additional_microscopes[microscope_name]["popup_window"].popup.dismiss()
self.additional_microscopes[microscope_name]["camera_view_controller"] = None
self.additional_microscopes[microscope_name][
"camera_view_controller"
] = None
del self.additional_microscopes[microscope_name]

def move_stage(self, pos_dict):
Expand Down
1 change: 1 addition & 0 deletions src/navigate/controller/sub_controllers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .camera_map import CameraMapSettingPopupController # noqa
from .microscope_popup import MicroscopePopupController # noqa
from .adaptive_optics import AdaptiveOpticsPopupController # noqa
from .histogram import HistogramController # noqa

# from .uninstall_plugin_controller import UninstallPluginController # noqa
from .plugins import PluginsController, UninstallPluginController # noqa
Expand Down
11 changes: 8 additions & 3 deletions src/navigate/controller/sub_controllers/acquire_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
p = __name__.split(".")[1]
logger = logging.getLogger(p)


class AcquireBarController(GUIController):
"""Acquire Bar Controller."""

Expand All @@ -59,6 +60,9 @@ def __init__(self, view, parent_controller):
"""
super().__init__(view, parent_controller)

#: AcquirePopUp: Instance of the popup window.
self.acquire_pop = None

#: str: Acquisition image mode.
self.mode = "live"

Expand Down Expand Up @@ -303,8 +307,8 @@ def launch_popup_window(self):
self.parent_controller.execute("stop_acquire")

elif self.is_save and self.mode != "live":
#: object: Instance of the popup save dialog.
self.acquire_pop = AcquirePopUp(self.view)

buttons = self.acquire_pop.get_buttons()
widgets = self.acquire_pop.get_widgets()

Expand All @@ -313,6 +317,9 @@ def launch_popup_window(self):
buttons["Done"].config(
command=lambda: self.launch_acquisition(self.acquire_pop)
)
self.acquire_pop.popup.bind(
"<Escape>", lambda e: self.acquire_pop.popup.dismiss()
)

# Configure drop down callbacks, will update save settings when file type is
# changed
Expand All @@ -326,9 +333,7 @@ def launch_popup_window(self):
else:
self.is_acquiring = True
self.view.acquire_btn.configure(state="disabled")
# self.view.pull_down.configure(state="disabled")
self.view.pull_down.state(["disabled", "readonly"])

self.parent_controller.execute("acquire")

def update_microscope_mode(self, *args):
Expand Down
7 changes: 4 additions & 3 deletions src/navigate/controller/sub_controllers/camera_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
p = __name__.split(".")[1]
logger = logging.getLogger(p)


class ABaseViewController(metaclass=abc.ABCMeta):
"""Abstract Base View Controller Class."""

Expand Down Expand Up @@ -100,7 +101,7 @@ def __init__(self, view, parent_controller=None):

Parameters
----------
view : tkinter.Frame
view : self.view.camera_waveform.camera_tab
The tkinter frame that contains the widgets.
parent_controller : Controller
The parent controller of the camera view controller.
Expand Down Expand Up @@ -958,7 +959,7 @@ def refresh(self, width, height):
if width == self.width and height == self.height:
return
self.canvas_width = width - self.view.lut.winfo_width() - 24
self.canvas_height = height - 85
self.canvas_height = height - 153
self.view.canvas.config(width=self.canvas_width, height=self.canvas_height)
self.view.update_idletasks()

Expand Down Expand Up @@ -1036,7 +1037,7 @@ def __init__(self, view, parent_controller=None):

Parameters
----------
view : tkinter.Frame
view : self.view.camera_waveform.camera_tab
The tkinter frame that contains the widgets.
parent_controller : Controller
The parent controller of the camera view controller.
Expand Down
Loading
Loading