Skip to content

Commit

Permalink
suggested autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
isahers1 committed Apr 26, 2022
1 parent 7dd99d4 commit d5e1804
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
75 changes: 74 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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('<KeyRelease>', get_typed)
entry_bar.bind('<Key>', detect_pressed)
entry_bar.bind('<BackSpace>', check_empty)



#entry_bar = AutocompleteCombobox(mainframe, width=50, textvariable=entry, completevalues = proof_methods)


showing = StringVar()
showing.set("Proof : Simple Abelian Proof\n--------------------------------")
Expand All @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion unique inverses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -24,3 +24,5 @@
p2.switchSidesOfEqual(8)
p.concludeSubproof(9)
p.qed(10)
'''
print(dir(Proof))

0 comments on commit d5e1804

Please sign in to comment.