
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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.
Example
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()
Output
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.
- Related Articles
- How to get the value of a button in the Entry widget using Tkinter?
- How to disable an Entry widget in Tkinter?
- Get contents of a Tkinter Entry widget
- 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?
- How to set the text/value/content of an 'Entry' widget using a button in Tkinter?
- How to set the font size of Entry widget in Tkinter?
- How to use a StringVar object in an Entry widget in Tkinter?
- How do I get an event callback when a Tkinter Entry widget is modified?
- How to set focus on Entry widget in Tkinter?
- How to connect a variable to the Tkinter Entry widget?
- Return the input of the Entry widget in Tkinter
- How to set the width of a Tkinter Entry widget in pixels?

Advertisements