在运行批处理文件时,如何最小化我的Tkinter窗口?

时间:2016-10-14 12:27:11

标签: python button tkinter onclick minimize

我有一个带按钮的Tkinter窗口。单击此按钮可运行批处理文件,该批处理文件又运行测试套件。到目前为止这个工作正常。但是,当我单击此按钮并在批处理文件执行完成时自行恢复时,我希望Tkinter窗口最小化。我不知道如何处理这个事件。帮助

脚本:

import Tkinter
import subprocess

top=Tkinter.Tk()

def callBatchFile():
    filepath=r"C:\TestFolder\ChangeManagementBatchFile.bat"
    p=subprocess.Popen(filepath,shell=True,stdout=subprocess.PIPE)
    stdout,stderr=p.communicate()
    print p.returncode

button=Tkinter.Button(top,text="Execute",command=callBatchFile)

button.pack()
top.mainloop()

1 个答案:

答案 0 :(得分:1)

top.wm_state('iconic')

应尽量减少你的胜利