Book Image

Python GUI Programming Cookbook

By : Burkhard Meier
Book Image

Python GUI Programming Cookbook

By: Burkhard Meier

Overview of this book

Table of Contents (18 chapters)
Python GUI Programming Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 created the title of a message box in the previous recipe. We will not reuse the code from the previous recipe, but instead we will build a new GUI in very few lines of Python code.

How to do it...

We can create a simple message box like this:

from...