How to create independent message boxes
In this recipe, we will create our tkinter message boxes as standalone top-level GUI windows.
You will first notice that, by doing so, we end up with an extra window, so we will explore ways to hide this window.
In the previous recipe, we invoked tkinter message boxes via our Help
| About
menu from our main GUI form.
So, why would we wish to create an independent message box?
One reason is that we might customize our message boxes and reuse them in several of our GUIs. Instead of having to copy and paste the same code into every Python GUI we design, we can factor it out of our main GUI code. This can create a small reusable component which we can then import into different Python GUIs.
Getting ready
We have already created the title of a message box in the previous recipe, Creating message boxes - information, warning, and error. We will not reuse the code from the previous recipe but build a new GUI using very few lines of Python code.
How to do it…
We can...