How it works...
First, we call the tkinter constructor of the Menu class. Then, we assign the newly created menu to our main GUI window. This, in fact, becomes the menu bar.
We save a reference to it in the instance variable named menu_bar.
Next, we create a menu and add a menu item to it. We then add a second menu item to the menu. The add_cascade() method aligns the menu items one below the other, in a vertical layout.
Then, we add a separator line between the two menu items. This is generally used to group related menu items and separate them from less related items (hence, the name).
Finally, we disable the tearoff dashed line to make our menu look much better.
Check the following GUI:
We then add a second menu to the menu bar. We can keep on adding menus through this technique.
Next, we create a function to quit our GUI application cleanly. This is the recommended Pythonic way to end the main event loop.
We bind the function we created to the menu item, using the tkinter's command property. Whenever we want our menu items to actually do something, we have to bind each of them to a function.