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 −