how to create python shell with tkterminal in python tkinter?

Viewed 113

I am creating a code editor and I want to create terminal for my code editor I have already created one with the help of tkterminal but it is not works as other python shell work in other code editors basically main problem is that my terminal that I have created with the help of tkterminal I unable to input() code this is my code(not full code short version of real one):

from tkinter import*
from tkinter.filedialog import askopenfilename, asksaveasfilename
from tkterminal import Terminal
def Open(event=None):
    global file 
    file = askopenfilename(defaultextension=".py",filetypes=[("Python","*.py")])
    if file == "":
        file = None
    else:
        editor.delete(1.0,END)
        with open(file,"r") as f:
            editor.insert(1.0,f.read())
def save(event=None):
    global file 
    if file == "":
        saveas()
    else:
        with open(file,"w") as f:
            f.write(editor.get(1.0,END))
def saveas(event=None):
    global file 
    file = asksaveasfilename(defaultextension=".py",filetypes=[("Python","*.py")])
    if file == "":
        file = None
    else:
        with open(file,"w") as f:
            f.write(editor.get(1.0,END))
def run(event=None):
    global file 
    if file == "":
        pass 
    else:
        command = f'python "{file}"'
        output.run_command(command,give_input=None)
    return "break"
root = Tk()
file = ""
editor = Text()
editor.pack()
output = Terminal(height=15)
output.shell = True
output.basename = "Code>>"
output.pack()
editor.bind("<Control-o>",Open)
editor.bind("<Control-s>",save)
editor.bind("<Control-Alt-s>",saveas)
editor.bind("<Shift-Return>",run)
root.mainloop()

this is what I am creating:- enter image description here

0 Answers
Related