我写了一个小python脚本,它刚弹出一个消息框,其中包含在命令行中传递的文本。我只想在未打开窗口(由上一个调用产生的窗口)时才将其弹出。
from Tkinter import *
import tkMessageBox
root = Tk()
root.withdraw()
# TODO not if a window with this title exists
tkMessageBox.showinfo("Key you!", " ".join(sys.argv[1:]))
知道如何检查吗?
最佳答案
我相信你想要:
if 'normal' != root.state():
tkMessageBox.showinfo("Key you!", " ".join(sys.argv[1:]))
关于python - 如何知道Tk中是否已经打开具有给定标题的窗口?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45540/