为什么在声明时执行Button参数“命令”?我是Python新手,想用tkinter编写一个程序。为什么执行下面的Hello函数?据我所知,只有在按下按钮时才会执行回调?我很困惑.。>>> def Hello():
print("Hi there!")>>> hi=Button(frame,text="Hello",command=Hello())Hi there!>>>
2 回答

白板的微信
TA贡献1883条经验 获得超3个赞
Button
command=Hello()
command=Hello
function_name
function_name()
>>> def func():... return 'hello'... >>> type(func)<type 'function'>>>> type(func())<type 'str'>
>>> hi=Button(frame, text="Hello", command=lambda: Goodnight("Moon"))
Goodnight("Moon")
添加回答
举报
0/150
提交
取消