How to create an Entry input field with Python and tkinter

Now, after the buttons and the labels, let’s see how to create the entry text field to get the input of an user in our GUI made with Python and tkiter.

import tkinter as tk


def enter(event):
	lab["text"] = entry.get()

root = tk.Tk()

entry = tk.Entry(
	root,
	font="Arial 20")
entry.pack()
entry.focus()
lab = tk.Label(
	root,
	text="...",
	font="Arial 20")
lab.pack()
entry.bind("<Return>", enter)
root.mainloop()

Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.