Skip to content

Commit 001fb28

Browse files
Merge pull request #1015 from TheDeanLab/1005-v2
1005 v2
2 parents a69c034 + 047a84d commit 001fb28

File tree

15 files changed

+564
-356
lines changed

15 files changed

+564
-356
lines changed

src/navigate/controller/configurator.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
class Configurator:
5959
"""Navigate Configurator"""
6060

61-
def __init__(self, root, splash_screen):
61+
def __init__(self, root: tk.Tk, splash_screen):
6262
"""Initiates the configurator application window.
6363
6464
Parameters
@@ -186,11 +186,12 @@ def set_value(temp_dict, key_list, value):
186186
if k.strip() == "":
187187
warning_info[hardware_name] = True
188188
print(
189-
f"Notice: {hardware_name} has an empty value {ref}! Please double check if it's okay!"
189+
f"Notice: {hardware_name} has an empty value "
190+
f"{ref}! Please double check if it's okay!"
190191
)
191192

192193
if k_idx in value_dict:
193-
k = value_dict[k_idx][v]
194+
k = value_dict[k_idx][v] # noqa
194195
v = variables[v_idx].get()
195196
if v_idx in value_dict:
196197
v = value_dict[v_idx][v]
@@ -208,7 +209,8 @@ def set_value(temp_dict, key_list, value):
208209
except tk._tkinter.TclError:
209210
v = ""
210211
print(
211-
f"Notice: {hardware_name} has an empty value {k}! Please double check!"
212+
f"Notice: {hardware_name} has an empty value {k}! "
213+
f"Please double check!"
212214
)
213215
warning_info[hardware_name] = True
214216
set_value(temp_dict, k.split("/"), v)
@@ -218,7 +220,9 @@ def set_value(temp_dict, key_list, value):
218220
if warning_info:
219221
messagebox.showwarning(
220222
title="Configuration",
221-
message=f"There are empty value(s) with {', '.join(warning_info.keys())}. Please double check!",
223+
message=f"There are empty value(s) with "
224+
f"{', '.join(warning_info.keys())}"
225+
f". Please double check!",
222226
)
223227

224228
def write_to_yaml(self, config, filename):
@@ -404,7 +408,7 @@ def build_widgets_value(widgets, value_dict):
404408
hardware_ref_name
405409
],
406410
)
407-
except Exception as e:
411+
except Exception:
408412
widgets_value = [None]
409413
microscope_tab.create_hardware_tab(
410414
hardware_type, widgets, hardware_widgets_value=widgets_value
@@ -425,7 +429,7 @@ def build_widgets_value(widgets, value_dict):
425429
],
426430
),
427431
]
428-
except:
432+
except Exception:
429433
widgets_value = [[None], [None]]
430434
microscope_tab.create_hardware_tab(
431435
hardware_type,

src/navigate/controller/controller.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import os
4141
import time
4242
import platform
43-
import reprlib
4443

4544
# Third Party Imports
4645

@@ -64,6 +63,7 @@
6463
FeaturePopupController,
6564
MenuController,
6665
PluginsController,
66+
HistogramController,
6767
# MicroscopePopupController,
6868
# AdaptiveOpticsPopupController,
6969
)
@@ -97,6 +97,7 @@
9797

9898
class Controller:
9999
"""Navigate Controller"""
100+
100101
def __init__(
101102
self,
102103
root,
@@ -198,8 +199,10 @@ def __init__(
198199
verify_waveform_constants(self.manager, self.configuration)
199200

200201
total_ram, available_ram = get_ram_info()
201-
logger.info(f"Total RAM: {total_ram / 1024**3:.2f} GB. "
202-
f"Available RAM: {available_ram / 1024**3:.2f} GB.")
202+
logger.info(
203+
f"Total RAM: {total_ram / 1024**3:.2f} GB. "
204+
f"Available RAM: {available_ram / 1024**3:.2f} GB."
205+
)
203206

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

227230
#: AcquireBarController: Acquire Bar Sub-Controller.
228-
self.acquire_bar_controller = AcquireBarController(self.view.acqbar, self)
231+
self.acquire_bar_controller = AcquireBarController(self.view.acquire_bar, self)
229232

230233
#: ChannelsTabController: Channels Tab Sub-Controller.
231234
self.channels_tab_controller = ChannelsTabController(
@@ -242,6 +245,10 @@ def __init__(
242245
self.view.camera_waveform.camera_tab, self
243246
)
244247

248+
self.histogram_controller = HistogramController(
249+
self.view.camera_waveform.camera_tab.histogram, self
250+
)
251+
245252
#: MIPSettingController: MIP Settings Tab Sub-Controller.
246253
self.mip_setting_controller = MIPViewController(
247254
self.view.camera_waveform.mip_tab, self
@@ -365,7 +372,7 @@ def update_buffer(self):
365372

366373
def update_acquire_control(self):
367374
"""Update the acquire control based on the current experiment parameters."""
368-
self.view.acqbar.stop_stage.config(
375+
self.view.acquire_bar.stop_stage.config(
369376
command=self.stage_controller.stop_button_handler
370377
)
371378

@@ -551,12 +558,14 @@ def refresh(width, height):
551558
height : int
552559
Height of the GUI.
553560
"""
554-
if width < 1200 or height < 600:
561+
if width < 1300 or height < 800:
555562
return
556563
self.view.camera_waveform["width"] = (
557-
width - self.view.frame_left.winfo_width() - 81
558-
)
559-
self.view.camera_waveform["height"] = height - 110
564+
width - self.view.left_frame.winfo_width() - 35
565+
) #
566+
self.view.camera_waveform["height"] = height - 117
567+
568+
print("camera_waveform height", self.view.camera_waveform["height"])
560569

561570
if event.widget != self.view.scroll_frame:
562571
return
@@ -1081,13 +1090,16 @@ def capture_image(self, command, mode, *args):
10811090
)
10821091
self.execute("stop_acquire")
10831092

1084-
# Display the Image in the View
1093+
# Display the image and update the histogram
10851094
self.camera_view_controller.try_to_display_image(
10861095
image=self.data_buffer[image_id]
10871096
)
10881097
self.mip_setting_controller.try_to_display_image(
10891098
image=self.data_buffer[image_id]
10901099
)
1100+
self.histogram_controller.populate_histogram(
1101+
image=self.data_buffer[image_id]
1102+
)
10911103
images_received += 1
10921104

10931105
# Update progress bar.
@@ -1212,7 +1224,9 @@ def display_images(
12121224
)
12131225
camera_view_controller.microscope_name = microscope_name
12141226
popup_window.popup.bind("<Configure>", camera_view_controller.resize)
1215-
self.additional_microscopes[microscope_name]["popup_window"] = popup_window
1227+
self.additional_microscopes[microscope_name][
1228+
"popup_window"
1229+
] = popup_window
12161230
self.additional_microscopes[microscope_name][
12171231
"camera_view_controller"
12181232
] = camera_view_controller
@@ -1226,7 +1240,9 @@ def display_images(
12261240
),
12271241
)
12281242

1229-
self.additional_microscopes[microscope_name]["show_img_pipe"] = show_img_pipe
1243+
self.additional_microscopes[microscope_name][
1244+
"show_img_pipe"
1245+
] = show_img_pipe
12301246
self.additional_microscopes[microscope_name]["data_buffer"] = data_buffer
12311247

12321248
# start thread
@@ -1263,7 +1279,9 @@ def destroy_virtual_microscope(self, microscope_name, destroy_window=True):
12631279
# destroy the popup window
12641280
if destroy_window:
12651281
self.additional_microscopes[microscope_name]["popup_window"].popup.dismiss()
1266-
self.additional_microscopes[microscope_name]["camera_view_controller"] = None
1282+
self.additional_microscopes[microscope_name][
1283+
"camera_view_controller"
1284+
] = None
12671285
del self.additional_microscopes[microscope_name]
12681286

12691287
def move_stage(self, pos_dict):

src/navigate/controller/sub_controllers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .camera_map import CameraMapSettingPopupController # noqa
1919
from .microscope_popup import MicroscopePopupController # noqa
2020
from .adaptive_optics import AdaptiveOpticsPopupController # noqa
21+
from .histogram import HistogramController # noqa
2122

2223
# from .uninstall_plugin_controller import UninstallPluginController # noqa
2324
from .plugins import PluginsController, UninstallPluginController # noqa

0 commit comments

Comments
 (0)