I have ScrolledText
in Tkiner
application ,in which i am supposed to write the python code in it and i have one button,by pressing that i send those lines of code to InteractiveInterpreter().runcode("code as a string")
This runcode()
method return the NoneType
object and shows output on the cmd
but i want output in string format, i tried using exec()
but it didn't work for me.There is some way to do that?
import Tkinter as tk
from Tkinter import *
from ScrolledText import *
from code import InteractiveInterpreter
interpreter = InteractiveInterpreter()
def go(event):
print(interpreter.runcode(textPad.get('1.0', END+'-1c')))
root = tk.Tk()
textPad = ScrolledText(root,width=100,height=100)
textPad.focus_set()
b2=tk.Button(root, text ="Run",width=34,height=3)
b2.pack()
b2.bind('<Button-1>', go)
textPad.pack()
root.mainloop()