我是Python新手并试图用tkinter编写程序.为什么下面的Hello函数被执行了?据我了解,回调只会在按下按钮时执行?我很迷茫...
>>> def Hello():
print("Hi there!")
>>> hi=Button(frame,text="Hello",command=Hello())
Hi there!
>>>
Run Code Online (Sandbox Code Playgroud) 我有一个tkinter脚本,在IDLE中运行得很好.但是,当我从Windows资源管理器中双击.py文件时,控制台窗口闪烁半秒然后退出.
我能够在控制台窗口上进行丝网印刷.它说:
...etc.etc...
NameError: global name 'simpledialog' is not defined
Run Code Online (Sandbox Code Playgroud)
simpledialog
是tkinter
我在我的脚本中使用的模块.像我一样from tkinter import *
,没有必要明确写tkinter.simpledialog
.
它在IDLE中工作,为什么不用.py?