How to do it...

Here are the steps to follow to create a message box in Python:

  1. Open GUI_tabbed_all_widgets_both_tabs.py from Chapter 2, Layout Management, and save the module as GUI_message_box.py.
  2. Add the following line of code to the top of the module where the import statements live:
from tkinter import messagebox as msg
  1. Next, create a callback function that will display a message box. We have to place the code of the callback above the code where we attach the callback to the menu item, because this is still procedural and not OOP code.

Add the following code just above the lines where we create the help menu:

def _msgBox():    msg.showinfo('Python Message Info Box', 'A Python GUI created     using tkinter:\nThe year is 2019.') 

The preceding ...

Get Python GUI Programming Cookbook - Third Edition 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.