【发布时间】:2014-03-24 01:53:33
【问题描述】:
我已经创建了 3 个脚本,现在我正在 Tkinter 中创建一个简单的前端菜单。当我单独使用这些脚本时,它们会正常工作并退出,所以我知道它们没有问题。问题一定出在我的菜单上(如下)。
从菜单中,我选择了一个工具,它调用另一个脚本并运行它。脚本只是挂起并等待,直到我在键盘上按回车键。当我按 Enter 键时,脚本会退出。我怎样才能让它自动退出而不是我必须按 Enter 键?
提前致谢。
from Tkinter import *
import Tkinter
import subprocess
root = Tkinter.Tk()
root.title("SimonsSoftware, 2014")
root.geometry('255x200+200+200')
text = Text(root)
text.insert(INSERT, "Please select which tool\nyou wish to use...")
def close_window():
root.withdraw()
def kill_window():
root.destroy()
def callDuff():
print "Call back works"
subprocess.Popen("python duff.duplicateFileFinder\duff.py", shell=True)
kill_window()
def callFibs():
print "Call back works"
subprocess.Popen("python fibs.FileInvestigationBiteSize\\fibs.py", shell=True)
close_window()
def callShift():
print "Call back works"
subprocess.Popen("python shift.SimonsHashInfoFinderTool\shift.py", shell=True)
close_window()
buttonOne = Tkinter.Button(root, text ="DUFF", relief=FLAT, command=callDuff)
buttonTwo = Tkinter.Button(root, text ="FIBS", relief=FLAT, command=callFibs)
buttonThree = Tkinter.Button(root, text ="SHIFT", relief=FLAT, command=callShift)
buttonOne.pack()
buttonTwo.pack()
buttonThree.pack()
text.pack()
root.mainloop()
【问题讨论】:
标签: python python-2.7 tkinter subprocess exit