Skip to content

Commit

Permalink
Merge pull request Claydough6#21 from Claydough6/GUI
Browse files Browse the repository at this point in the history
Added error popup window
  • Loading branch information
Claydough6 authored May 4, 2021
2 parents 48a5daa + f614428 commit 28a0ce8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
22 changes: 6 additions & 16 deletions gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from resolution_canvas import ResolutionCanvas
from statement_frame import StatementFrame
from info_window import InfoWindow

class ResolutionGUI():
def __init__(self):
Expand Down Expand Up @@ -38,22 +39,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_window.grid_columnconfigure(0, weight=1)
help_window.grid_rowconfigure(0, weight=1)

s = ttk.Sizegrip(help_window)
s.grid(column=1, row=1, sticky=(S,E))

help_text = "Error..."
with open('help.txt', 'r') as f:
help_text = f.read()

label = Text(help_window, wrap="word")
label.insert("1.0", help_text)
label.configure(state="disabled")
label.grid(row=0, column=0, padx=10, pady=10, sticky=(N,S,E,W))
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
Expand Down
22 changes: 22 additions & 0 deletions info_window.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 28a0ce8

Please sign in to comment.