我新尝试为布尔解释器编写基于GUI的python代码 请解决此错误以帮助我 下面是我在python中的代码 代码:
def solve():
strMinterms = app.minterms.get()
strDontCare = app.dontcare.get()
strVarNum = app.varNum.get()
getLists = validate(strMinterms,strDontCare,strVarNum)
if getLists !=False:
app.min_exp.delete(0,END)
app.min_imp.delete(0,END)
answer = minimize(getLists[0],getLists[1],int(strVarNum))
for i in answer:
app.min_imp.insert(END,i)
expr = format_minimized_expression(answer)
for i in expr:
app.min_exp.insert(END,i)
else:
messagebox.showerror("Bad input","Illegal values, please try again")
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack(side=LEFT)
Label(frame,text="variable Number :").grid(row=2,column=0,sticky=W)
self.varNum = Entry(frame,bg="white")
self.varNum.grid(row=2,column=1,sticky=W+E)
Label(frame,text="minterms :").grid(row=0,column=0,sticky=W)
self.minterms = Entry(frame,bg="white",width=35)
self.minterms.grid(row=0,column=1,sticky=W)
Label(frame,text="dontcare :").grid(row=1,column=0,sticky=W)
self.dontcare = Entry(frame,bg="white",width=35)
self.dontcare.grid(row=1,column=1,sticky=W)
Label(frame,text="### Minimized Implicants ###").grid(row=3,column=1,sticky=W+E)
self.min_imp=Listbox(frame,bg="white",height=8,width=4)
self.min_imp.grid(row=4,column=1,sticky=W+E)
Label(frame,text="### Solution ###").grid(row=5,columnspan=2,sticky=W+E)
self.min_exp=Listbox(frame,bg="white",height=8,width=4)
self.min_exp.grid(row=6,columnspan=2,sticky=W+E)
self.solve = Button(frame, text="Solve", command=solve)
self.solve.grid(row=7,columnspan = 2,sticky=W+E)
self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.grid(row=8,columnspan = 2,sticky=W+E)
root = Tk()
root.resizable(0,0)
root.title("Boolean Interpreter")
app = App(root)
root.mainloop()
在编译代码后,我无法理解这种代码中的类型错误,但确实显示了小部件,但是当我输入值时,它显示如下错误: 现在出现这样的错误:
错误:
Tkinter回调中的异常 追溯(最近一次通话):
File "C:\Users\Vivek\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "D:\python\workspace\min\min.py", line 219, in solve answer = minimize(getLists[0],getLists[1],int(strVarNum)) TypeError: 'NoneType' object is not subscriptable