0

I'm making an ide using tkinter and i have to create a terminal for it and I found a method to give output and get output to cmd but when i try to insert it's output to terminal that is text widget than my program is not responding and I have to close my program here is my some piece of code please help!

import os
from tkinter import *

def ts():
    a = float(t.index('end-1c linestart')) -1
    b = t.get(a,END)
    for i in os.popen(b,"r"): 
        break

root = Tk()

t = Text()
t.pack()

Button(command=ts,text="dsfdsfd").pack()

root.mainloop()

  • You might be interested in https://stackoverflow.com/questions/59164314/how-can-i-create-a-small-idle-like-python-shell-in-tkinter/59290540#59290540 – j_4321 Jul 26 '22 at 10:05

1 Answers1

0

I've modified your code a bit. Does this work for you?

import os
from tkinter import *

def ts():
  a = float(t.index('end-1c linestart')) -1
  b = t.get(a,END)
  os.system(b)


root = Tk()

t = Text()
t.pack()

Button(command=ts,text="dsfdsfd").pack()

root.mainloop()
  • Thank! for try to help me but sorry it's still same problem happening. When I give a wrong command like any thing it gives an error that cmd give us and doesn't crash but when I give right command like python than the problem happen thanks again – Tanmay Sahu Jul 26 '22 at 12:13