python 2.7 - tkinter button to open new window and run script -
i have tkinter button want use run existing python script in new cmd window. how that? can new cmd window appear, how run script in it?
thanks, chris.
multiline code more readable if edit question add (allowed, mark edited , in comment) rather in comment.
from tkinter import * sys import executable subprocess import popen, create_new_console import os def delprof(): popen(["cmd.exe"], creationflags=create_new_console) `
if console prompt, can run python or else. run particular python program, following works me (3.4).
from tkinter import * subprocess import call pyprog = 'tem2.py' def callpy(): call(['python', '-i', pyprog] ) root = tk() button(root, text='run', command=callpy).pack() root.mainloop()
when running program, console disappears when program ends. prevent python program, output can seen, either put like
input('hit enter exit')
at end of program or start '-i', did above. allows execution of additional interactive statements examine result
Comments
Post a Comment