How to do it...

First, we'll have to import the Menu class from tkinter. Add the following line of code to the top of the Python module, where the import statements live:

Next, we will create the menu bar. Add the following code towards the bottom of the module, just above where we create the main event loop:
GUI_menubar_tearoff.py

In line 119, we are calling the constructor of the imported Menu module class and pass in our main GUI instance, win. We save an instance of the Menu object in the menu_bar variable. In line 120, we configure our ...

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