Skip to content
Merged

1005 v2 #1015

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
44 changes: 31 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,10 @@ def __init__(
self.view.camera_waveform.camera_tab, self
)

self.histogram_controller = HistogramController(
self.view.camera_waveform.camera_tab.histogram, 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 +372,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 +558,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 +1090,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 +1224,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 +1240,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 +1279,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
Loading
Loading