Tkinter has a Menu widget class that can be used for many kinds of menus, including top menu bars. As any other widget classes, menus are instantiated with the parent container as the first argument and some optional configuration options:
import tkinter as tk
class App(tk.Tk):
def __init__(self):
super().__init__()
menu = tk.Menu(self)
file_menu = tk.Menu(menu, tearoff=0)
file_menu.add_command(label="New file")
file_menu.add_command(label="Open")
file_menu.add_separator()
file_menu.add_command(label="Save")
file_menu.add_command(label="Save as...")
menu.add_cascade(label="File", menu=file_menu)
menu.add_command(label="About")
menu.add_command(label="Quit", command=self.destroy)
self.config(menu=menu)
if __name__ == "__main__":
app = App()
app.mainloop()
If you run the preceding script, you can see that the File entry shows the secondary menu, and you can close the application by clicking the Quit menu button.