- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the value of an Entry widget in Tkinter?
Let us suppose that we have created an Entry widget and we want to get the value of it. In this case, we can use the .get() method. It maps the input object into a variable which can be used further to print or display the entered value.
In this example, we will create an application that will display the input text thorough a label widget.
#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set the geometry of tkinter frame win.geometry("750x250") def get_value(): e_text=entry.get() Label(win, text=e_text, font= ('Century 15 bold')).pack(pady=20) #Create an Entry Widget entry= ttk.Entry(win,font=('Century 12'),width=40) entry.pack(pady= 30) #Create a button to display the text of entry widget button= ttk.Button(win, text="Enter", command= get_value) button.pack() win.mainloop()
Running the above code will display a window that contains an entry widget and a button.
In the given output, if we will click the Enter button. It will mimic the input value from the Entry widget.
- How to get the value of a button in the Entry widget using Tkinter?
- Get contents of a Tkinter Entry widget
- How to disable an Entry widget in Tkinter?
- How to use the 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?
- How to insert the current time in an Entry Widget in Tkinter?
- Return the input of the Entry widget in Tkinter
- How to set the font size of Entry widget in Tkinter?
- How to set the text/value/content of an 'Entry' widget using a button in Tkinter?
- How to connect a variable to the Tkinter Entry widget?
- How to set the width of a Tkinter Entry widget in pixels?
- Getting the Cursor position in Tkinter Entry widget
- How to use a StringVar object in an Entry widget in Tkinter?
- How to set focus on Entry widget in Tkinter?