diff --git a/gui.py b/gui.py index 79263ab..0d93186 100644 --- a/gui.py +++ b/gui.py @@ -4,6 +4,16 @@ from proof import * from tkinter.scrolledtext import ScrolledText import fitz +from ttkwidgets.autocomplete import AutocompleteCombobox + + +proof_methods = ['MultElem', 'accessAssumption', 'andElim', 'breakPower', 'cancelLeft', +'cancelRight', 'closure', 'combinePower', 'concludeSubproof', 'forAllIntroduction', 'forallElim', +'identleft', 'identright', 'impliesIntroduction', 'introAssumption', 'introCases', 'introElement', +'introGroup', 'introReflexive', 'introSubproof', 'inverseElimLHS', 'inverseElimRHS', 'leftMult', +'leftSidesEq', 'modus', 'notElim', 'qed', 'reduceLogic', 'rightMult', 'rightSidesEq', 'show', +'showReturn', 'splitPowerAddition', 'splitPowerMult', 'substituteLHS', 'substituteRHS', +'switchSidesOfEqual', 'thereexistsElim', 'undo', 'writeLaTeXfile'] class PDFViewer(ScrolledText): def show(self, pdf_file): @@ -53,9 +63,69 @@ def generateLaTeX(*args): pdf1.grid(row=5, column=1, sticky='nsew') pdf1.show('Simple Abelian Proof.pdf') + +def match_string(): + hits = [] + got = entry_bar.get() + for item in proof_methods: + if item.startswith(got): + hits.append(item) + return hits + +def match_string_del(): + hits = [] + got = entry_bar.get()[:-1] + for item in proof_methods: + if item.startswith(got): + hits.append(item) + return hits + +def check_empty(event): + if len(entry_bar.get()) == 1: + suggestions.set("") + else: + hits = match_string_del() + show_hit(hits) + +def get_typed(event): + if len(event.keysym) == 1: + hits = match_string() + show_hit(hits) + +def show_hit(lst): + suggestions.set(lst) + if len(lst) == 1: + entry.set(lst[0]) + detect_pressed.filled = True + entry_bar.icursor(END) + +def detect_pressed(event): + key = event.keysym + if len(key) == 1 and detect_pressed.filled is True: + pos = entry_bar.index(INSERT) + entry_bar.delete(pos, END) + +detect_pressed.filled = False + + entry = StringVar() -entry_bar = ttk.Entry(mainframe, width=50, textvariable=entry) +entry_bar = Entry( + mainframe, + width = 50, + bg='black', + insertbackground='white', + fg='white', + textvariable=entry) entry_bar.grid(column=1, row=3, sticky=(W, E)) +entry_bar.focus_set() +entry_bar.bind('', get_typed) +entry_bar.bind('', detect_pressed) +entry_bar.bind('', check_empty) + + + +#entry_bar = AutocompleteCombobox(mainframe, width=50, textvariable=entry, completevalues = proof_methods) + showing = StringVar() showing.set("Proof : Simple Abelian Proof\n--------------------------------") @@ -66,6 +136,9 @@ def generateLaTeX(*args): ttk.Button(mainframe, text="Generate Latex", command=generateLaTeX).grid(column=3, row=4, sticky=W) +suggestions = StringVar() +showSuggestions = ttk.Label(mainframe, width = 50, background="white", textvariable=suggestions).grid(column=1, row=4, sticky=(W, E)) + for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) diff --git a/unique inverses.py b/unique inverses.py index 005533e..56e31e2 100644 --- a/unique inverses.py +++ b/unique inverses.py @@ -5,7 +5,7 @@ from integer import * from logicObjects import * - +''' G = group('G','*') inversePropertyOne = Eq( Mult(['a','c']) , Mult([G.identity_identifier]) , G) inversePropertyTwo = Eq( Mult(['a','d']) , Mult([G.identity_identifier]) , G) @@ -24,3 +24,5 @@ p2.switchSidesOfEqual(8) p.concludeSubproof(9) p.qed(10) +''' +print(dir(Proof))