TypeError:“Label”对象不是callab

2024-04-26 10:04:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个简单的pythongui,它使用标签将gif图像绑定到函数。但是,它返回错误TypeError: 'Label' object not callable

代码如下:

from tkinter import *

tk = Tk()
mode = 'draw'
filename = PhotoImage(file = 'bin\\Images\\pencil.gif')
draw = Label(tk, image=filename, width=53, height=47)
draw.place(x = 60, y = 620)
draw.img = filename
draw.bind('<Double-Button-1>', draw)
filename = PhotoImage(file = 'bin\\Images\\select.gif')
select = Label(tk, image=filename, width=53, height=46)
select.place(x = 160, y = 620)
select.img = filename
select.bind('<Double-Button-1>', select)
filename = PhotoImage(file = 'bin\\Images\\select_all.gif')
select_all = Label(tk, image=filename, width=53, height=48)
select_all.place(x = 260, y = 620)
select_all.img = filename
select_all.bind('<Double-Button-1>', select_all)
filename = PhotoImage(file = 'bin\\Images\\delete.gif')
delete = Label(tk, image=filename, width=50, height=45)
delete.place(x = 360, y = 620)
delete.img = filename
delete.bind('<Double-Button-1>', delete)
filename = PhotoImage(file = 'bin\\Images\\instrument_choose.gif')
inst = Label(tk, image=filename, width=355, height=51)
inst.place(x = 700, y = 620)
inst.img = filename
inst.bind('<Double-Button-1>', draw)

回溯读取中没有显示为我文件中的行的行号。这些函数没有任何参数,它们所做的是继续到下一行。你知道吗


Tags: imagebinallfilenamedeletewidthgifselect