![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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
How to get an Entry box within a Messagebox in Tkinter?
There are various methods and built-in functions available with the messagebox library in tkinter. Let's assume you want to display a messagebox and take some input from the user in an Entry widget. In this case, you can use the askstring library from simpledialog. The askstring library creates a window that takes two arguments, the title of the window, and the input title before the Entry widget. Let's take an example to understand how it works.
Example
# Import the required library from tkinter import * from tkinter.simpledialog import askstring from tkinter.messagebox import showinfo # Create an instance of tkinter frame and window win=Tk() win.geometry("700x300") name = askstring('Name', 'What is your name?') showinfo('Hello!', 'Hi, {}'.format(name)) win.mainloop()
Output
Running the above code will display a popup message box asking the user to enter the name in the given Entry widget.
Enter the name and click "OK". It will display the following message −
Advertisements