diff --git a/src/user_interface.py b/src/user_interface.py index da7c259..90fcfc9 100644 --- a/src/user_interface.py +++ b/src/user_interface.py @@ -1357,7 +1357,10 @@ class HardwareConfiguration(Frame): # open file selection dialogue at current path and save path of selected file filename = filedialog.askopenfilename(initialdir=directory, title="Select Config File", filetypes=(("Config File", "*.ini*"), ("All Files", "*.*"))) - if os.path.exists(filename): # does the file exist? + if filename == () or filename == '': + # this happens when file selection window is closed without selecting a file + ui_print("No file selected, could not load config.") + elif os.path.exists(filename): # does the file exist? config.CONFIG_FILE = filename # set global config file to the new file config.CONFIG_OBJECT = config.get_config_from_file(filename) # load from config file to config object config.check_config(config.CONFIG_OBJECT) # check and display warnings if values are out of bounds @@ -1365,8 +1368,6 @@ class HardwareConfiguration(Frame): ui_print("\nReinitializing devices...") g.CAGE_DEVICE.reconnect_hardware_async() # reinitialize devices and program with new values self.update_fields() # update entry fields to show new values - elif filename == '': # this happens when file selection window is closed without selecting a file - ui_print("No file selected, could not load config.") else: # file does not exist ui_print("Selected file", filename, "does not exist, could not load config.")