O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A menu bar

The top menu bar of an application usually just contains other menus, such as file and edit. These are known as "cascades" in Tkinter, and are essentially a menu inside a menu. This may be confusing at first, so let's begin with a very simple example to demonstrate the difference between a menu and a cascade.

Create a new Python file called menu.py and add the following code:

import tkinter as tkwin = tk.Tk()win.geometry('400x300')lab = tk.Label(win, text="Demo application")menu = tk.Menu(win)

After importing Tkinter and creating a main window and Label, we make our first Menu widget. As with a lot of widgets, the first argument needed is the master, or parent, in which the widget will be drawn. We draw this menu in our main window ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required