Compare commits
No commits in common. "027a88342e70367055f8ac2566cd2c3bb30d6011" and "a3d6129baddf2752e9521823dd1d0e843aa3b205" have entirely different histories.
027a88342e
...
a3d6129bad
20
main.py
20
main.py
|
@ -16,8 +16,6 @@ default_configuration = {
|
|||
# empty configuration by default because new values will be added while trying to load them
|
||||
# this allows the IDE to load old configuration files with missing keys
|
||||
configuration = {}
|
||||
home_directory = os.path.expanduser("~")
|
||||
config_file_path = os.path.join(home_directory, "some_ide_config.json")
|
||||
|
||||
def info(message):
|
||||
# print info to sys.stderr because it isn’t really output, just debug information
|
||||
|
@ -54,17 +52,6 @@ def get_configuration_value(key):
|
|||
return None
|
||||
return configuration[key]
|
||||
|
||||
def set_configuration_value(key, value, save_to_disk=True):
|
||||
if not key in configuration:
|
||||
info("Writing configuration for previously unknown key "+str(key)+".")
|
||||
configuration[key]=value
|
||||
try:
|
||||
config_file = open(config_file_path, "w")
|
||||
config_file.write(json.dumps(configuration))
|
||||
config_file.close()
|
||||
except:
|
||||
error("Failed to save config file.")
|
||||
|
||||
# easy way to get data out of window events
|
||||
class Window_Interaction_Handler:
|
||||
# constructor
|
||||
|
@ -120,6 +107,8 @@ class Window_Interaction_Handler:
|
|||
################################################################################
|
||||
|
||||
# read configuration
|
||||
home_directory = os.path.expanduser("~")
|
||||
config_file_path = os.path.join(home_directory, "some_ide_config.json")
|
||||
if os.path.isfile(config_file_path):
|
||||
try:
|
||||
config_file = open(config_file_path, "r")
|
||||
|
@ -252,9 +241,4 @@ def rebuild_menu():
|
|||
|
||||
rebuild_menu()
|
||||
|
||||
def handle_exit():
|
||||
set_configuration_value("window geometry", main_window.geometry())
|
||||
main_window.destroy()
|
||||
|
||||
main_window.protocol("WM_DELETE_WINDOW", handle_exit)
|
||||
main_window.mainloop()
|
||||
|
|
Reference in New Issue