Python TypeError:/:';浮动';。简单绘图程序

Python TypeError:/:';浮动';。简单绘图程序,python,matplotlib,tkinter,typeerror,Python,Matplotlib,Tkinter,Typeerror,我正在写一个程序,它通过在GUI中使用滑块调整参数来绘图 这是我的代码: 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() epsilo

我正在写一个程序,它通过在GUI中使用滑块调整参数来绘图

这是我的代码:

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(canopy)收到此错误消息

所以我的问题有三个部分:

  • 这个信息是什么意思

  • 如何使这个程序工作

  • “错误信息”这个词合适吗?我们如何称呼这些信息


  • 关于您的每个问题:

  • 错误消息表示您正试图将浮点对象除以实例方法(函数)对象

  • 因为
    get
    Scale
    类的一个实例方法,所以必须这样调用它:

    V=epsilon.get()*(math.exp(-r/sigma.get())-(2/sigma.get())**6)
    #            ^^                       ^^              ^^
    
    否则,您将使用
    get
    函数对象本身执行计算

  • 是的,你可以这么说。术语“回溯”通常指整个错误输出:

    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'
    
    而“错误消息”通常仅指最后一行:

    TypeError: unsupported operand type(s) for /: 'float' and 'instancemethod'
    
  • TypeError: unsupported operand type(s) for /: 'float' and 'instancemethod'