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'
所以我的問題有三個部分:
什麼這個消息是什麼意思?
如何使該程序起作用?
是「錯誤信息」正確的詞嗎?我們如何稱呼這些信息?