How to create independent message boxes

In this recipe, we will create our tkinter message boxes as stand-alone top-level GUI windows.

We 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 ...

Get Python GUI Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.