I have coded a gui with buttons and when I press one button I want it to run a .py script that displays a graph, so the graph has to open in a different view altogether.
The .py
file for the graph runs perfectly on its own but I am trying to implement it into my GUI upon clicking a button (I've used Tkinter) - I have done this using subprocess for a different .py
file, but the output is saved instead of being printed at the bottom.
So I am unsure how to do a like a python test.py upon clicking a button for it to open in a separate window.
The second button should be able to run a .py file, but the output should be shown in a text file instead of printing at the bottom of the console.
This is what I have so far:
def visualise():
#with open(" .png", "r") as output:
command = ("python test.py")
p = subprocess.Popen(command, shell=True)
p.send_signal(signal.SIGINT)
print 'completed'
buttongraph = Tkinter.Button(self, text="generate graph", command=visualise) buttongraph.pack()
(The print does print but the command does not execute and I also removed the stderr
, because the output line of the code does not work. I was just playing around with it.)