Text box widgets
In tkinter
, the typical textbox widget is called Entry
. In this recipe, we will add such an Entry
to our GUI. We will make our label more useful by describing what the Entry
is doing for the user.
Getting ready
This recipe builds upon the Creating buttons and changing their text property recipe.
How to do it...
# Modified Button Click Function # 1 def clickMe(): # 2 action.configure(text='Hello ' + name.get()) # Position Button in second row, second column (zero-based) action.grid(column=1, row=1) # Changing our Label # 3 ttk.Label(win, text="Enter a name:").grid(column=0, row=0) # 4 # Adding a Textbox Entry widget # 5 name = tk.StringVar() # 6 nameEntered = ttk.Entry(win, width=12, textvariable=name) # 7 nameEntered.grid(column=0, ...
Get Python GUI Programming Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.