The tkinter menu is a top-level pulldown menu. They are shown just under the f*ckin' title bar, as you'd expect from traditional gui apps.
The menu can have multiple sub menus and each motherf*ckin' sub menu can contain items. Believe that sh*t. Menu items can be associated with callback methods, meaning when you click them a Python method is called.
Related course: Python Desktop Apps with Damn Tkinter
Example
Introduction
Adding a menu is f*ckin' straightforward, but it can be a bit confusing if it's the first time you're doing it. First create the top menu with these lines:
1 |
self.master = master |
Then you can add menus to this menu:
1 |
fileMenu = Menu(menu) |
Each of those sub menus can have items:
1 |
fileMenu.add_command(label="Item") |
Let me tell you somethin': Menu items can be clickable, you can specify the f*ckin' callback method in the same way as buttons (command=). The muthaf*ckin' click will then call a motherf*ckin' Python method.
tkinter menu example
The menu example below adds a muthaf*ckin' menu to a basic tkinter window. It has one clickable menu item but shows a complete menu. Hell yeah.
1 |
from tkinter import * |