Tkinter is a Python module to create cross-platform GUI applications. This module comes with Python’s standard library. In this answer, we’ll learn to create a text box in Tkinter
.
We will use the Entry
widget to create a text box in Tkinter.
tkinter.Entry()
Let’[s take a look at an example of this.
#import tkinter module import tkinter as tk #create window window = tk.Tk() #provide size to window window.geometry("300x300") #add text label tk.Label(text="Enter Name").pack() #add text box tk.Entry().pack() window.mainloop()
Line 2: We import the tkinker
module.
Line 5: We create a tkinker
instance and assign it to the variable window.
Line 8: We set the window size as 300x300.
Line 11: We create a label to display text.
Line 14: We create a text box using Entry()
.
Once the text box is created, we can enter text into it.
Free Resources