Compare commits
2 Commits
060b8e81d8
...
14c19f3d69
Author | SHA1 | Date |
---|---|---|
BodgeMaster | 14c19f3d69 | |
BodgeMaster | 4c9bdca77a |
107
main.py
107
main.py
|
@ -103,7 +103,7 @@ class Window_Interaction_Handler:
|
|||
warn("__window_interactions not empty upon destruction of Window_Interaction_Handler:\n"+str(self.__window_interactions))
|
||||
|
||||
################################################################################
|
||||
# PROGRAM START
|
||||
# PROGRAM STARTUP
|
||||
################################################################################
|
||||
|
||||
# read configuration
|
||||
|
@ -139,7 +139,8 @@ else:
|
|||
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.Label(dialog, text="Failed to save the initial config file.\n" +
|
||||
"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()
|
||||
|
@ -148,6 +149,108 @@ else:
|
|||
# exit with success exit code anyway because this is not a program failure
|
||||
sys.exit(EXIT_SUCCESS)
|
||||
|
||||
################################################################################
|
||||
# PROGRAM MAIN WINDOW
|
||||
################################################################################
|
||||
|
||||
main_window = tk.Tk()
|
||||
main_window.title("IDE")
|
||||
main_window.geometry(get_configuration_value("window geometry"))
|
||||
|
||||
def not_implemented():
|
||||
warn("Not implemented!")
|
||||
|
||||
# format:
|
||||
# "":{} -> menu or submenu
|
||||
# "":function -> menu entry
|
||||
# "":None -> disabled menu entry
|
||||
# None:None -> separator
|
||||
#
|
||||
# Entries with ... at the end are supposed to open dialogs whereas entries without dots are supposed to take effect immediately
|
||||
menu_structure = {
|
||||
"IDE": {
|
||||
"Preferences...": not_implemented,
|
||||
"Quit": not_implemented
|
||||
},
|
||||
"Project": {
|
||||
"New": {
|
||||
"No known project types": None
|
||||
},
|
||||
"Open...": not_implemented,
|
||||
"Close": {
|
||||
"No open projects": None
|
||||
},
|
||||
None: None,
|
||||
"Preferences...": not_implemented,
|
||||
"Search...": not_implemented,
|
||||
"Build": not_implemented
|
||||
},
|
||||
"File": {
|
||||
"New...": not_implemented,
|
||||
"Open...": not_implemented,
|
||||
"Save": not_implemented,
|
||||
"Close": not_implemented,
|
||||
None: None,
|
||||
"Rename...": not_implemented,
|
||||
"Move...": not_implemented,
|
||||
"View in File Explorer...": not_implemented
|
||||
},
|
||||
"Edit": {
|
||||
"Cut": not_implemented,
|
||||
"Copy": not_implemented,
|
||||
"Paste": not_implemented,
|
||||
None: None,
|
||||
"Search and Replace...": not_implemented,
|
||||
None: None,
|
||||
"Format": not_implemented,
|
||||
"Indent": not_implemented,
|
||||
"Unindent": not_implemented,
|
||||
"Toggle Comment": not_implemented
|
||||
},
|
||||
"View": {
|
||||
"Zoom in": not_implemented,
|
||||
"Zoom out": not_implemented,
|
||||
"Normal Size": not_implemented
|
||||
},
|
||||
"Help": {
|
||||
"Manual...": not_implemented,
|
||||
"About IDE...": not_implemented,
|
||||
}
|
||||
}
|
||||
|
||||
menubar = None
|
||||
def build_menu(structure_dict, menu):
|
||||
for entry in structure_dict:
|
||||
if structure_dict[entry]==None:
|
||||
if entry==None:
|
||||
info("Adding separator for " + str(entry))
|
||||
menu.add_separator()
|
||||
else:
|
||||
info("Adding disabled entry for " + str(entry))
|
||||
menu.add_command(label=entry)
|
||||
menu.entryconfig(entry, state="disabled")
|
||||
if isinstance(structure_dict[entry], dict):
|
||||
info("Adding submenu for " + str(entry))
|
||||
submenu = tk.Menu(menu, tearoff=False)
|
||||
build_menu(structure_dict[entry], submenu)
|
||||
menu.add_cascade(label=entry, menu=submenu)
|
||||
if callable(structure_dict[entry]):
|
||||
info("Adding entry for "+str(entry))
|
||||
menu.add_command(label=entry, command=structure_dict[entry])
|
||||
|
||||
def rebuild_menu():
|
||||
menubar = tk.Menu(main_window)
|
||||
menubar = build_menu(menu_structure, menubar)
|
||||
main_window.config(menu=menubar)
|
||||
|
||||
rebuild_menu()
|
||||
#menubar = tk.Menu(main_window)
|
||||
#menus = {}
|
||||
#menus["Project"] = tk.Menu(menubar, tearoff=False)
|
||||
#menus["Project"].add_command(label="Open...", command=not_implemented)
|
||||
#menus["Project>Close"] = tk.Menu(menus["Project"], tearoff=False)
|
||||
#menus["Project"].add_cascade(label="Close", menu=menus["Project>Close"])
|
||||
#menubar.add_cascade(label="Project", menu=menus["Project"])
|
||||
#main_window.config(menu=menubar)
|
||||
|
||||
main_window.mainloop()
|
||||
|
|
Reference in New Issue