-1
Я пытаюсь сделать Tk-окно как консоль python. Но моя проблема заключается в том, когда приходит многострочный код. Как я могу compille_command()
и runcode()
если ввод многострочного: например, если True: печать (что-то) или I в пределах (х)Как скомпилировать многострочный код python
from tkinter import *
import code,skuska
class Display:
def __init__(self):
self.frame = Tk()
self.entry = Entry(self.frame)
self.entry.pack()
self.button = Button(self.frame,text="DoIt", command=self.vypis)
self.button.pack()
self.output = Text(self.frame)
self.output.pack()
self.konzola = code.InteractiveInterpreter()
self.out = skuska.Capturing()
def vypis(self):
compiledText = self.kompiluj(self.entry.get())
with skuska.Capturing() as self.out:
self.konzola.runcode(compiledText)
self.output.insert(END,str(self.out)+'\n')
print('OUTPUT IS :' , self.out)
def kompiluj(self,kod):
return code.compile_command(kod)
def loop(self):
self.frame.mainloop()
if __name__ == '__main__':
Display().loop()