diff --git a/main.py b/main.py index 7481360..035d24e 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,10 @@ import sys, os, json, traceback EXIT_SUCCESS=0 EXIT_ERROR=1 +default_configuration = { + "window geometry": "640x480" +} + def warn(message, is_exception=False): print("WARNING: "+str(message), file=sys.stderr) if is_exception: @@ -85,8 +89,8 @@ class Window_Interaction_Handler: # read configuration home_directory = os.path.expanduser("~") config_file_path = os.path.join(home_directory, "some_ide_config.json") -# default configuration -configuration = {} +# load default configuration in case it is needed +configuration = default_configuration if os.path.isfile(config_file_path): try: config_file = open(config_file_path, "r") @@ -108,8 +112,18 @@ else: dialog.mainloop() if dialog_interaction_handler.get_result("create"): - #TODO: store default configuration - warn("Not implemented!") + try: + config_file = open(config_file_path, "w") + config_file.write(json.dumps(default_configuration)) + config_file.close() + except: + warn("Failed to save initial config file.", is_exception=True) + dialog = tk.Tk() + dialog.title("Failed to save initial config file") + ttk.Label(dialog, text="Failed to save the initial config file. The IDE can still start up, but it is likely that all changes to the configuration will be lost where they would be saved otherwise.").pack() + ttk.Button(dialog, text="Continue", command=dialog.destroy).pack() + dialog.resizable(0,0) + dialog.mainloop() else: error("No config present and user chose not to create one. Exiting.", is_exception=False, handle_gracefully=True) # exit with success exit code anyway because this is not a program failure