O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting text input

We now know how to get Boolean information from our user, but what if we want to get something more detailed, such as text?

Tkinter provides us with the perfect widget to do just this – Entry.

An Entry widget is a one-line text entry box which is put into a parent widget just like a Label or Button. The special Tkinter variables can be attached to an Entry to make getting the value out a breeze.

Why don't we add some personalization to our Hello World application? Grab your code and adjust it to the following:

class Window(tk.Tk):    def __init__(self):        super().__init__()        self.title("Hello Tkinter")        self.label_text = tk.StringVar()        self.label_text.set("My Name Is: ")        self.name_text = tk.StringVar() self.label = tk.Label(self, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required