33
33
import tkinter as tk
34
34
from time import sleep
35
35
from tkinter import filedialog , messagebox
36
+ from typing import Optional
36
37
37
38
# Third Party Imports
38
39
@@ -87,35 +88,30 @@ def __init__(self, root: tk.Tk, splash_screen):
87
88
self .microscope_id = 0
88
89
self .create_config_window (0 )
89
90
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 :
96
92
"""Closes the window and exits the program"""
97
93
self .root .destroy ()
98
94
exit ()
99
95
100
- def add_microscope (self ):
96
+ def add_microscope (self ) -> None :
101
97
"""Add a new microscope tab"""
102
98
self .microscope_id += 1
103
99
self .create_config_window (self .microscope_id )
104
100
105
- def delete_microscopes (self ):
101
+ def delete_microscopes (self ) -> None :
106
102
"""Delete all microscopes"""
107
103
# delete microscopes
108
104
for tab_id in self .view .microscope_window .tabs ():
109
105
self .view .microscope_window .forget (tab_id )
110
106
self .view .microscope_window .tab_list = []
111
107
self .microscope_id = 0
112
108
113
- def new_configuration (self ):
109
+ def new_configuration (self ) -> None :
114
110
"""Create new configurations"""
115
111
self .delete_microscopes ()
116
112
self .create_config_window (self .microscope_id )
117
113
118
- def save (self ):
114
+ def save (self ) -> None :
119
115
"""Save configuration file"""
120
116
121
117
def set_value (temp_dict , key_list , value ):
@@ -225,7 +221,7 @@ def set_value(temp_dict, key_list, value):
225
221
f". Please double check!" ,
226
222
)
227
223
228
- def write_to_yaml (self , config , filename ) :
224
+ def write_to_yaml (self , config : dict , filename : str ) -> None :
229
225
"""write yaml file
230
226
231
227
Parameters
@@ -256,8 +252,14 @@ def write_func(prefix, config_dict, f):
256
252
f .write ("microscopes:\n " )
257
253
write_func (" " , config , f )
258
254
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
+ """
261
263
262
264
tab_name = "Microscope-" + str (id )
263
265
microscope_tab = MicroscopeTab (
@@ -285,11 +287,26 @@ def create_config_window(self, id):
285
287
sticky = tk .NSEW ,
286
288
)
287
289
288
- def load_configuration (self ):
290
+ def load_configuration (self ) -> None :
289
291
"""Load configuration"""
290
292
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
+ """
293
310
value = value_dict
294
311
for key in name .split ("/" ):
295
312
if key .strip () == "" :
@@ -300,7 +317,7 @@ def get_widget_value(name, value_dict):
300
317
return value
301
318
302
319
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"""
304
321
temp = {}
305
322
for key in widgets :
306
323
if key == "frame_config" :
@@ -327,7 +344,7 @@ def get_widgets_value(widgets, value_dict):
327
344
return temp
328
345
329
346
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"""
331
348
if widgets is None or value_dict is None :
332
349
return [None ]
333
350
result = []
0 commit comments