0
我正在编写一个程序,绘制Lennard-Jones potential,并在GUI中使用滑块调整参数。TypeError:不支持的操作数类型为/:'float'。简单的绘图程序
这是我的代码:
from Tkinter import *
import pylab as p
import math
def show_values():
V=epsilon.get*(math.exp(-r/sigma.get)-(2/sigma.get)**6)
p.plot(r,V)
p.show()
r = p.arange(0.1, 0.2, 0.01)
master = Tk()
epsilon = Scale(master, from_=-10,length=300, to=30, resolution=0.1, width=100)
epsilon.pack()
sigma = Scale(master, from_=-50, to=25, length=300,resolution=0.1, orient=HORIZONTAL)
sigma.pack()
Button(master, text='Show', command=show_values).pack()
mainloop()
但我从我的IDE收到此错误信息(树冠)
%run C:/Users/PC/Desktop/lenard.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\PC\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.4.1.1975.win-x86\lib\lib-tk\Tkinter.py", line 1470, in __call__
return self.func(*args)
File "C:\Users\PC\Desktop\lenard.py", line 7, in show_values
V=epsilon.get*(math.exp(-r/sigma.get)-(2/sigma.get)**6)
TypeError: unsupported operand type(s) for /: 'float' and 'instancemethod'
所以我的问题有三个部分:
什么这个消息是什么意思?
如何使该程序起作用?
是“错误信息”正确的词吗?我们如何称呼这些信息?