Skip to content

Commit 001f502

Browse files
Merge pull request #1019 from TheDeanLab/small-fixes
Small fixes...
2 parents 001fb28 + 156bef8 commit 001f502

File tree

6 files changed

+154
-109
lines changed

6 files changed

+154
-109
lines changed

src/navigate/controller/configurator.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import tkinter as tk
3434
from time import sleep
3535
from tkinter import filedialog, messagebox
36+
from typing import Optional
3637

3738
# Third Party Imports
3839

@@ -87,35 +88,30 @@ def __init__(self, root: tk.Tk, splash_screen):
8788
self.microscope_id = 0
8889
self.create_config_window(0)
8990

90-
print(
91-
"WARNING: The Configuration Assistant is not fully implemented. "
92-
"Users are still required to manually configure their system."
93-
)
94-
95-
def on_cancel(self):
91+
def on_cancel(self) -> None:
9692
"""Closes the window and exits the program"""
9793
self.root.destroy()
9894
exit()
9995

100-
def add_microscope(self):
96+
def add_microscope(self) -> None:
10197
"""Add a new microscope tab"""
10298
self.microscope_id += 1
10399
self.create_config_window(self.microscope_id)
104100

105-
def delete_microscopes(self):
101+
def delete_microscopes(self) -> None:
106102
"""Delete all microscopes"""
107103
# delete microscopes
108104
for tab_id in self.view.microscope_window.tabs():
109105
self.view.microscope_window.forget(tab_id)
110106
self.view.microscope_window.tab_list = []
111107
self.microscope_id = 0
112108

113-
def new_configuration(self):
109+
def new_configuration(self) -> None:
114110
"""Create new configurations"""
115111
self.delete_microscopes()
116112
self.create_config_window(self.microscope_id)
117113

118-
def save(self):
114+
def save(self) -> None:
119115
"""Save configuration file"""
120116

121117
def set_value(temp_dict, key_list, value):
@@ -225,7 +221,7 @@ def set_value(temp_dict, key_list, value):
225221
f". Please double check!",
226222
)
227223

228-
def write_to_yaml(self, config, filename):
224+
def write_to_yaml(self, config: dict, filename: str) -> None:
229225
"""write yaml file
230226
231227
Parameters
@@ -256,8 +252,14 @@ def write_func(prefix, config_dict, f):
256252
f.write("microscopes:\n")
257253
write_func(" ", config, f)
258254

259-
def create_config_window(self, id):
260-
"""Creates the configuration window tabs."""
255+
def create_config_window(self, id: int) -> None:
256+
"""Creates the configuration window tabs.
257+
258+
Parameters
259+
----------
260+
id : int
261+
The id of the microscope
262+
"""
261263

262264
tab_name = "Microscope-" + str(id)
263265
microscope_tab = MicroscopeTab(
@@ -285,11 +287,26 @@ def create_config_window(self, id):
285287
sticky=tk.NSEW,
286288
)
287289

288-
def load_configuration(self):
290+
def load_configuration(self) -> None:
289291
"""Load configuration"""
290292

291-
def get_widget_value(name, value_dict):
292-
"""Get the value from a dict"""
293+
def get_widget_value(name, value_dict) -> Optional[str]:
294+
"""Get the value from a dict
295+
296+
Parameters
297+
----------
298+
name: str
299+
key name
300+
value_dict: dict
301+
value dictionary
302+
303+
Returns
304+
-------
305+
value : Optional[str]
306+
307+
- The value of the key if it exists
308+
- None if the key does not exist
309+
"""
293310
value = value_dict
294311
for key in name.split("/"):
295312
if key.strip() == "":
@@ -300,7 +317,7 @@ def get_widget_value(name, value_dict):
300317
return value
301318

302319
def get_widgets_value(widgets, value_dict):
303-
"""Get all key-value from valude_dict, keys are from widgets"""
320+
"""Get all key-value from value_dict, keys are from widgets"""
304321
temp = {}
305322
for key in widgets:
306323
if key == "frame_config":
@@ -327,7 +344,7 @@ def get_widgets_value(widgets, value_dict):
327344
return temp
328345

329346
def build_widgets_value(widgets, value_dict):
330-
"""According to valude_dict build values for widgets"""
347+
"""According to value_dict build values for widgets"""
331348
if widgets is None or value_dict is None:
332349
return [None]
333350
result = []

src/navigate/controller/controller.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,8 @@ def set_mode_of_sub(self, mode):
604604
605605
Parameters
606606
__________
607-
mode : string
608-
string = 'live', 'stop'
607+
mode : str
608+
The string = 'live', 'stop'
609609
"""
610610
self.channels_tab_controller.set_mode(mode)
611611
self.camera_view_controller.set_mode(mode)
@@ -634,8 +634,9 @@ def execute(self, command, *args):
634634
Parameters
635635
__________
636636
command : string
637-
string = 'stage', 'stop_stage', 'move_stage_and_update_info',
638-
args* : function-specific passes.
637+
The string includes 'stage', 'stop_stage', 'move_stage_and_update_info',
638+
args* : Iterable.
639+
Function-specific passes
639640
"""
640641

641642
if command == "joystick_toggle":
@@ -1163,10 +1164,10 @@ def display_images(
11631164
camera_view_controller : CameraViewController
11641165
Camera View Controller object.
11651166
show_img_pipe : multiprocessing.Pipe
1166-
Pipe for showing images.
1167+
The pipe for showing images.
11671168
data_buffer : SharedNDArray
11681169
Pre-allocated shared memory array.
1169-
Size dictated by x_pixels, y_pixels, an number_of_frames in
1170+
Size dictated by x_pixels, y_pixels, and number_of_frames in
11701171
configuration file.
11711172
"""
11721173
camera_view_controller.initialize_non_live_display(
@@ -1379,8 +1380,8 @@ def register_event_listener(self, event_name, event_handler):
13791380
----------
13801381
event_name : string
13811382
Name of the event.
1382-
event_handler : function
1383-
Function to handle the event.
1383+
event_handler : callable
1384+
The function to handle the event.
13841385
"""
13851386
self.event_listeners[event_name] = event_handler
13861387

0 commit comments

Comments
 (0)