Tkinter Text Entry

Tkinter apps can accept text input from the user.

The examples assume that you already have a program with Tkinter imported and a Tk object called root. Example setup:

from Tkinter import *
root = Tk()

#example code goes here

root.mainloop()

(If you import Tkinter in a different way or create a main object with a different name, you will have to change the examples accordingly.)

Entry Widget

Documentation for Entry Widget

Creating an Entry widget and adding it to your app:

entrybox = Entry(root)
entrybox.pack()

Getting the user input from the Entry widget:

response = entrybox.get()

This .get() function will probably need to be used in a callback function, such as the function linked to a button.

Example:

def clicked():
    L['text'] = 'Button clicked: ' + entrybox.get()
    
entrybox = Entry(root)
entrybox.pack()

b = Button(root, text="Submit", command=clicked)
b.pack()

L = Label(root, text="Enter text")
L.pack()