diff --git a/gui_main.py b/gui_main.py index 1f65321..51eba9e 100644 --- a/gui_main.py +++ b/gui_main.py @@ -5,6 +5,7 @@ from resolution_canvas import ResolutionCanvas from statement_frame import StatementFrame from resolution_engine import ResolutionEngine +from info_window import InfoWindow class ResolutionGUI(): def __init__(self): @@ -42,13 +43,11 @@ def __init__(self): # used to display the help menu def get_help(self, *args): - help_window = Toplevel(self.root) - help_window.title("Help Window") - help_text = "Error..." - with open('help.txt', 'r') as f: - help_text = f.read() - label = ttk.Label(help_window, text=help_text) - label.grid(padx=10, pady=10) + help_window = InfoWindow(self.root, "Help Window", "help.txt", file=True) + + # used to display an error to the user + def show_error(self, error_text): + error_window = InfoWindow(self.root, "Error Window!", error_text) def update_clause_premise(self, index, conclusion=False): # get the clause frame that is selected diff --git a/info_window.py b/info_window.py new file mode 100644 index 0000000..380446b --- /dev/null +++ b/info_window.py @@ -0,0 +1,22 @@ +from tkinter import * +from tkinter import ttk + +class InfoWindow: + def __init__(self, master, title, text_or_file, file=False): + window = Toplevel(master) + window.title(title) + window.grid_columnconfigure(0, weight=1) + window.grid_rowconfigure(0, weight=1) + + s = ttk.Sizegrip(window) + s.grid(column=1, row=1, sticky=(S,E)) + + text = text_or_file + if file: + with open(text_or_file, 'r') as f: + text = f.read() + + label = Text(window, wrap="word") + label.insert("1.0", text) + label.configure(state="disabled") + label.grid(row=0, column=0, padx=10, pady=10, sticky=(N,S,E,W))