当按下按钮时调用小部件时,第一个参数必须是可调用的

2024-09-28 21:42:38 发布

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

我试着做一个按钮,当按下它的时候会调用整个画面

这是按钮:

self.inboxbtn = Button(self.root, text="INBOX", font=("Fixedsys", 20, "bold"), bg="#06E63B", fg="#A3FC7C", command=self.inboxing)

这是函数“self.inboxing”

def inboxing(self):
    self.inframe.place_forget()
    self.outframe.place_forget()
    self.comframe.place_forget()
    self.mesframe.place_forget()

    self.inhead = Checkbutton(self.inframe, text="| FROM | SUBJECT |", font=("Fixedsys", 20, "bold"), width = 58, height = 2)
    self.inhead.pack()
    self.incounter = 0
    for curr in os.listdir(self.inboxpath):
        inpath = os.path.join("server/users/"+self.loguser+"/inbox/"+curr)
        f = open(inpath, "r")
        intitle = f.read()
        print inpath
        f.close()
        self.incounter += 1
        self.chck = Checkbutton(self.inframe, text=curr, font=("Consolas", 10), command=partial(self.inboxbtn, intitle))
        self.chck.pack()

        self.inframe.place(x = self.xbox, y = self.ybox, width = self.wbox, height = self.hbox)

这是错误:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1547, in call return self.func(*args)
File "C:\Users\Shirgene\Desktop\PYTHON\mainpage.py", line 138, in inboxing
self.chck = Checkbutton(self.inframe, text=curr, font=("Consolas", 10), command=partial(self.inboxbtn, intitle))
TypeError: the first argument must be callable


Tags: textinselfplacecommandfontforgetcurr