2022-02-14 13:04:51 +01:00
|
|
|
#!/usr/bin/python3
|
2022-02-15 20:03:45 +01:00
|
|
|
import os
|
2022-02-14 13:04:51 +01:00
|
|
|
import tkinter as tk
|
|
|
|
from tkinter import ttk
|
2022-02-15 20:38:33 +01:00
|
|
|
import gui_helper
|
|
|
|
from config import Config
|
2022-02-14 13:04:51 +01:00
|
|
|
|
2022-02-14 13:18:51 +01:00
|
|
|
################################################################################
|
2022-02-15 20:03:45 +01:00
|
|
|
# CONSTANTS
|
2022-02-14 13:18:51 +01:00
|
|
|
################################################################################
|
|
|
|
|
2022-02-14 14:04:45 +01:00
|
|
|
default_configuration = {
|
|
|
|
"window geometry": "640x480"
|
|
|
|
}
|
2022-02-15 20:03:45 +01:00
|
|
|
configuration_file_path = os.path.join(os.path.expanduser("~"), "some_ide_config.json")
|
2022-02-14 13:04:51 +01:00
|
|
|
|
2022-02-14 13:18:51 +01:00
|
|
|
################################################################################
|
2022-02-14 23:58:48 +01:00
|
|
|
# PROGRAM STARTUP
|
2022-02-14 13:18:51 +01:00
|
|
|
################################################################################
|
2022-02-14 13:04:51 +01:00
|
|
|
|
2022-02-15 20:38:33 +01:00
|
|
|
configuration = Config(configuration_file_path, default_configuration)
|
2022-02-14 13:04:51 +01:00
|
|
|
|
2022-02-14 23:58:48 +01:00
|
|
|
################################################################################
|
|
|
|
# PROGRAM MAIN WINDOW
|
|
|
|
################################################################################
|
|
|
|
|
2022-02-14 14:36:03 +01:00
|
|
|
main_window = tk.Tk()
|
2022-02-14 23:59:25 +01:00
|
|
|
main_window.title("IDE")
|
2022-02-15 20:38:33 +01:00
|
|
|
main_window.geometry(configuration.get_configuration_value("window geometry"))
|
2022-02-14 23:59:25 +01:00
|
|
|
|
|
|
|
menubar = None
|
2022-02-15 20:03:45 +01:00
|
|
|
def rebuild_menu(structure_dict):
|
2022-02-14 23:59:25 +01:00
|
|
|
menubar = tk.Menu(main_window)
|
2022-02-15 20:03:45 +01:00
|
|
|
gui_helper.build_menu(structure_dict, menubar)
|
2022-02-14 23:59:25 +01:00
|
|
|
main_window.config(menu=menubar)
|
|
|
|
|
2022-02-15 20:03:45 +01:00
|
|
|
rebuild_menu(gui_helper.menu_structure)
|
2022-02-14 23:59:25 +01:00
|
|
|
|
2022-02-15 01:58:50 +01:00
|
|
|
def handle_exit():
|
2022-02-15 20:38:33 +01:00
|
|
|
configuration.set_configuration_value("window geometry", main_window.geometry())
|
2022-02-15 01:58:50 +01:00
|
|
|
main_window.destroy()
|
|
|
|
|
|
|
|
main_window.protocol("WM_DELETE_WINDOW", handle_exit)
|
2022-02-14 14:36:03 +01:00
|
|
|
main_window.mainloop()
|