Adding menu items

Next, we will add menu items in every individual menu. Not surprisingly, the code for the menu items needs to be added in the respective menu instance, as shown in the following screenshot:

In our example, we will add menu items to the File, Edit, and About menus (2.02.py).

The View menu has certain menu item variations, which will be tackled in the following section and are therefore not dealt with here.

Menu items are added by using the add_command() method. The format used to add menu items is as follows:

my_menu.add_command(label="Menu Item Label", accelerator='KeyBoard Shortcut', compound='left', image=my_image, underline=0, ...

Get Tkinter GUI Application Development Blueprints - 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.