Compare commits

..

No commits in common. "060b8e81d879c6974b9aaa9b8cd807fbcc80cfda" and "e39368bf41bb46c9b1dd862ddbd878ef083a8bc8" have entirely different histories.

1 changed files with 10 additions and 23 deletions

33
main.py
View File

@ -13,14 +13,6 @@ EXIT_ERROR=1
default_configuration = {
"window geometry": "640x480"
}
# 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 = {}
def info(message):
# print info to sys.stderr because it isnt really output, just debug information
print("INFO: "+str(message), file=sys.stderr)
traceback.print_stack()
def warn(message, is_exception=False):
print("WARNING: "+str(message), file=sys.stderr)
@ -40,18 +32,6 @@ def error(message, is_exception=True, handle_gracefully=True):
else:
sys.exit(EXIT_ERROR)
def get_configuration_value(key):
if key in configuration:
pass
else:
info("Requested configuration value for "+str(key)+" not in configuration. Loading from default configuration.")
try:
configuration[key] = default_configuration[key]
except KeyError:
error("Requested an invalid configuration key.")
return None
return configuration[key]
# easy way to get data out of window events
class Window_Interaction_Handler:
# constructor
@ -109,6 +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")
# 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")
@ -148,6 +130,11 @@ else:
# exit with success exit code anyway because this is not a program failure
sys.exit(EXIT_SUCCESS)
main_window = tk.Tk()
main_window.geometry(get_configuration_value("window geometry"))
main_window.mainloop()
#window = tk.Tk()
#frame = ttk.Frame(window, padding=10)
#frame.grid()
#ttk.Label(frame, text="Hello, World!").grid(column=0, row=0)
#ttk.Button(frame, text="Quit", command=window.destroy).grid(column=0, row=1)
#window.mainloop()