我正在编写一个在 python 中触发佳能的模拟,我得到了错误:
Traceback (most recent call last):
File "C:\Users\Casper\Desktop\Skole\Dropbox\Skråkast\det_skraa_kast.py", line 47, in <module>
float(speed)
AttributeError: Entry instance has no attribute '__float__'
我的代码(对不起丹麦人的名字:-):
#==LabelFrame==#
labelframe = LabelFrame(master, text="Parametre for affyring", bd = 3, font=("Aeria", "8", "bold"))
labelframe.pack(side = BOTTOM, expand="yes", fill="both")
#--Indtastning af fart--#
speedlabel = Label(labelframe, text="Indtast farten af kuglen", font=("Aeria", "8", "bold"))
speedlabel.pack(side = TOP)
speed = Entry(labelframe, bd = 3)
speed.pack(side = TOP)
float(speed)
#--Indtasning af vinkel--#
anglelabel = Label(labelframe, text="Indtast vinklen af kanonen", font=("Aeria", "8", "bold"))
anglelabel.pack(side = TOP)
angle = Entry(labelframe, bd = 3)
angle.pack()
float(angle)
... code creating a coordinate system ...
#==Update knap==#
def update(event=None):
speedentry = speed.get()
angleentry = angle.get()
真的希望你能帮助我:-)
最好的问候,卡斯帕
ps 可能值得注意的是我正在运行 2.7.3(我的老师要求)