From the course: Python GUI Development with Tkinter

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Entering single-line text with the Entry widget

Entering single-line text with the Entry widget

From the course: Python GUI Development with Tkinter

Start my 1-month free trial

Entering single-line text with the Entry widget

- [Instructor] When you need your user to enter a short text string, for example a user name or password, you should use the entry widget. It provides a simple one-line text entry box for the user to type in the information. However, it is limited to only one line, so if you need the user to enter multiple lines of text then you'll need to use the text widget which is covered in later video segments. I've already imported the tkinter package as well as the tkinter module, and created a top level root window here, so let's go ahead and create an entry widget. We do so by calling the ttk module and then the entry constructor method. The first parameter, of course, is the parent widget which will be my top level window. And then I'm also going to set the property for width. I'll set that to 30. Let's use the pack method to add the entry widget to our top level window. So I did here with this width method, that controls the size of the entry field. And that's specified in number of…

Contents