在编写一个简单计算器的时候,出现了command错误的反馈,我改了很久一直找不到错在哪,command是Button里面的参数,但为什么回出现unknown option “-commmand”????
代码如下,希望路过的大神帮我看看TvT
出错的地方和对应的函数已经用#号标准
##一个满足基本运算(+-*/)、开方(sqrt)、求倒数(1/x)、切换正负号(±)的计算器
import tkinter, decimal, math
root = tkinter.Tk()
root.resizable(0, 0)
root.title('计算器')
vartext = tkinter.StringVar() #只存储数字,包括负数,即字符串首位数字可能为-/+号
symbol = None
result = None
temp_sotre = []
class Entry:
global vartext, symbol, result, temp_sotre
def __init__(self, entry):
self.current_input = entry
def func_Connect(self): ################################出错的函数###########
temp_sotre.append(self.current_input)
vartext.set(''.join(temp_sotre))
print(vartext.get())
def func_Plus_or_Minus(self):
if vartext.get():
if float(vartext.get())>0:
temp_sotre.insert(0,'-')
vartext.set(''.join(temp_sotre))
elif float(vartext.get())==0:
pass
else:
temp_sotre.insert(0, '+')
vartext.set(''.join(temp_sotre))
else:
temp_sotre.append('-')
vartext.set(''.join(temp_sotre))
def func_Decimal(self):
if temp_sotre.count('.') >= 1:
pass
else:
temp_sotre.append(self.current_input)
vartext.set('