- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return the input of the Entry widget in Tkinter
An Entry widget in Tkinter is nothing but an input widget that accepts single-line user input in a text field. To return the data entered in an Entry widget, we have to use the get() method. It returns the data of the entry widget which further can be printed on the console.
The following example will return the input data that can be used to display in the window with the help of a Label Widget as well.
#Import the required libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("700x250") # Define a function to return the Input data def get_data(): label.config(text= entry.get(), font= ('Helvetica 13')) #Create an Entry Widget entry = Entry(win, width= 42) entry.place(relx= .5, rely= .5, anchor= CENTER) #Inititalize a Label widget label= Label(win, text="", font=('Helvetica 13')) label.pack() #Create a Button to get the input data ttk.Button(win, text= "Click to Show", command= get_data).place(relx= .7, rely= .5, anchor= CENTER) win.mainloop()
If we will execute the above code, it will display a window with an Entry widget and a button to display the input on the screen.
Now, click the "Click to Show" button and it will display the user input on the canvas.
- How to use the Entry widget in Tkinter?
- Getting the Cursor position in Tkinter Entry widget
- Get contents of a Tkinter Entry widget
- How to get the value of an Entry widget in Tkinter?
- How to set the font size of Entry widget in Tkinter?
- Setting the focus to a specific Tkinter entry widget
- How to set the width of a Tkinter Entry widget in pixels?
- How to disable an Entry widget in Tkinter?
- How to connect a variable to the Tkinter Entry widget?
- How to clear Text widget content while clicking on the Entry widget itself in Tkinter?
- How to get the value of a button in the Entry widget using Tkinter?
- How to insert the current time in an Entry Widget in Tkinter?
- How to set focus on Entry widget in Tkinter?
- How to change the Entry Widget Value with a Scale in Tkinter?
- How to interactively validate an Entry widget content in tkinter?