from User_Interface import HelmholtzGUI import cage_func as func import traceback import globals as g from os.path import exists try: # start normal operations g.CONFIG_FILE = 'config.ini' if not exists(g.CONFIG_FILE): print("Config file not found, creating new from defaults.") func.create_default_config(g.CONFIG_FILE) print("Starting setup...") func.setup_axes() # initiate communication, set handles print("\nOpening User Interface...") g.app = HelmholtzGUI() func.ui_print("Program Initialized") func.ui_print("Starting setup...") func.setup_axes() # initiate communication, set handles g.app.mainloop() g.app = None # reset to None so nothing tries to print in the UI output except BaseException as e: # if there is an error, print what happened func.ui_print("\nAn error occurred, Shutting down.") func.ui_print(e) func.ui_print(traceback.print_exc()) finally: # safely shut everything down at the end func.shut_down_all()