2024-03-28 09:22:54 发布
网友
from Tkinter import * class Program: def __init__(self): b = Button(text="click me", command=self.callback("1")) b.pack() def callback(self,s): print "clicked!" program = Program() mainloop()
为什么单击按钮之前要执行函数??*/你知道吗
应该将函数引用传递给command参数。否则,您将就地执行该函数。你知道吗
command
b = Button(text="click me", command=self.callback) # Or if you want to pass parameters b = Button(text="click me", command=lambda: self.callback("1"))
应该将函数引用传递给
command
参数。否则,您将就地执行该函数。你知道吗相关问题 更多 >
编程相关推荐