I am looking for a way to be able to run a python command from a Tkinter GUI. (I am using python 2.7.)
Example:
import Tkinter
root = Tk()
def run():
print 'smth'
def runCommand():
code...
button = Button(root, text = 'smth', command = run).pack()
entry = Entry(root, width = 55, justify = 'center').pack()
entry_button = Button(root, text = 'Run', command = runCommand).pack()
root.mainloop()
I would like to type print 'hello'
in the entry and when I press Run button it actually runs the command print 'hello'
How is this doable? If it is not, than can I add a command line widget in Tkinter?