Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes... #1019

Merged
merged 2 commits into from
Oct 23, 2024
Merged
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
53 changes: 35 additions & 18 deletions src/navigate/controller/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import tkinter as tk
from time import sleep
from tkinter import filedialog, messagebox
from typing import Optional

# Third Party Imports

Expand Down Expand Up @@ -87,35 +88,30 @@ def __init__(self, root: tk.Tk, splash_screen):
self.microscope_id = 0
self.create_config_window(0)

print(
"WARNING: The Configuration Assistant is not fully implemented. "
"Users are still required to manually configure their system."
)

def on_cancel(self):
def on_cancel(self) -> None:
"""Closes the window and exits the program"""
self.root.destroy()
exit()

def add_microscope(self):
def add_microscope(self) -> None:
"""Add a new microscope tab"""
self.microscope_id += 1
self.create_config_window(self.microscope_id)

def delete_microscopes(self):
def delete_microscopes(self) -> None:
"""Delete all microscopes"""
# delete microscopes
for tab_id in self.view.microscope_window.tabs():
self.view.microscope_window.forget(tab_id)
self.view.microscope_window.tab_list = []
self.microscope_id = 0

def new_configuration(self):
def new_configuration(self) -> None:
"""Create new configurations"""
self.delete_microscopes()
self.create_config_window(self.microscope_id)

def save(self):
def save(self) -> None:
"""Save configuration file"""

def set_value(temp_dict, key_list, value):
Expand Down Expand Up @@ -225,7 +221,7 @@ def set_value(temp_dict, key_list, value):
f". Please double check!",
)

def write_to_yaml(self, config, filename):
def write_to_yaml(self, config: dict, filename: str) -> None:
"""write yaml file

Parameters
Expand Down Expand Up @@ -256,8 +252,14 @@ def write_func(prefix, config_dict, f):
f.write("microscopes:\n")
write_func(" ", config, f)

def create_config_window(self, id):
"""Creates the configuration window tabs."""
def create_config_window(self, id: int) -> None:
"""Creates the configuration window tabs.

Parameters
----------
id : int
The id of the microscope
"""

tab_name = "Microscope-" + str(id)
microscope_tab = MicroscopeTab(
Expand Down Expand Up @@ -285,11 +287,26 @@ def create_config_window(self, id):
sticky=tk.NSEW,
)

def load_configuration(self):
def load_configuration(self) -> None:
"""Load configuration"""

def get_widget_value(name, value_dict):
"""Get the value from a dict"""
def get_widget_value(name, value_dict) -> Optional[str]:
"""Get the value from a dict

Parameters
----------
name: str
key name
value_dict: dict
value dictionary

Returns
-------
value : Optional[str]

- The value of the key if it exists
- None if the key does not exist
"""
value = value_dict
for key in name.split("/"):
if key.strip() == "":
Expand All @@ -300,7 +317,7 @@ def get_widget_value(name, value_dict):
return value

def get_widgets_value(widgets, value_dict):
"""Get all key-value from valude_dict, keys are from widgets"""
"""Get all key-value from value_dict, keys are from widgets"""
temp = {}
for key in widgets:
if key == "frame_config":
Expand All @@ -327,7 +344,7 @@ def get_widgets_value(widgets, value_dict):
return temp

def build_widgets_value(widgets, value_dict):
"""According to valude_dict build values for widgets"""
"""According to value_dict build values for widgets"""
if widgets is None or value_dict is None:
return [None]
result = []
Expand Down
17 changes: 9 additions & 8 deletions src/navigate/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,8 @@ def set_mode_of_sub(self, mode):

Parameters
__________
mode : string
string = 'live', 'stop'
mode : str
The string = 'live', 'stop'
"""
self.channels_tab_controller.set_mode(mode)
self.camera_view_controller.set_mode(mode)
Expand Down Expand Up @@ -634,8 +634,9 @@ def execute(self, command, *args):
Parameters
__________
command : string
string = 'stage', 'stop_stage', 'move_stage_and_update_info',
args* : function-specific passes.
The string includes 'stage', 'stop_stage', 'move_stage_and_update_info',
args* : Iterable.
Function-specific passes
"""

if command == "joystick_toggle":
Expand Down Expand Up @@ -1163,10 +1164,10 @@ def display_images(
camera_view_controller : CameraViewController
Camera View Controller object.
show_img_pipe : multiprocessing.Pipe
Pipe for showing images.
The pipe for showing images.
data_buffer : SharedNDArray
Pre-allocated shared memory array.
Size dictated by x_pixels, y_pixels, an number_of_frames in
Size dictated by x_pixels, y_pixels, and number_of_frames in
configuration file.
"""
camera_view_controller.initialize_non_live_display(
Expand Down Expand Up @@ -1379,8 +1380,8 @@ def register_event_listener(self, event_name, event_handler):
----------
event_name : string
Name of the event.
event_handler : function
Function to handle the event.
event_handler : callable
The function to handle the event.
"""
self.event_listeners[event_name] = event_handler

Expand Down
Loading
Loading