I'm writing an IDE for python, in python, and need to use subprocess to intereact with a user's script.
I am completely new to using subprocess and not sure what I'm doing here. I've created a test snippet representing what I'm trying to do:
from subprocess import Popen,PIPE,STDOUT
import tkinter as tk
t=tk.Text()
t.pack()
p = Popen(["python","c:/runme.py"],stdout=PIPE,stdin=PIPE,stderr=PIPE,shell=True)
p.stdin.write("5".encode())
out=p.stdout.read()
t.insert(1.0,out)
And here is the test script I'm trying to interact with:
print("Hello World")
inp=input("Enter a Number: ")
print(inp)
quit()
Unfortunately it just waiting (presumably) on line 2. How do I read what has already been printed and how to I then input the string?