

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Taking input from the user in Tkinter
There might be times when we need to take the user input in our Tkinter application. We can get the user Input in a Single Line text input through the Entry widget using get() method. To display the Captured input, we can either print the message on the screen or display the input with the help of the Label widget.
Example
#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win= Tk() #Set the geometry of Tkinter frame win.geometry("750x250") def display_text(): global entry string= entry.get() label.configure(text=string) #Initialize a Label to display the User Input label=Label(win, text="", font=("Courier 22 bold")) label.pack() #Create an Entry widget to accept User Input entry= Entry(win, width= 40) entry.focus_set() entry.pack() #Create a Button to validate Entry Widget ttk.Button(win, text= "Okay",width= 20, command= display_text).pack(pady=20) win.mainloop()
Output
Running the above code will display a window that will contain an entry widget that accepts the single line User Input.
Now, write some text in the given entry widget and press "Okay" to validate and display the entry widget on the screen.
- Related Questions & Answers
- Taking input from console in Python
- Taking multiple inputs from user in Python
- Taking input in Python
- How to populate an array one value at a time by taking input from user in Java?
- Java Program to Get Input from the User
- Take Matrix input from user in Python
- How to get the input from the Tkinter Text Widget?
- Python Get a list as input from user
- How to get the input from a Checkbox in Python Tkinter?
- Can we read from JOptionPane by requesting input from user in Java?
- How do I print and have user input in a text box in Tkinter?
- How to create input Pop-Ups (Dialog) and get input from user in Java?
- Make JavaScript take HTML input from user, parse and display?
- Get number from user input and display in console with JavaScript
- How to input multiple values from user in one line in C#?
Advertisements