Answer
In Tkinter, you can display a menu bar by creating an instance of the Menu widget and then adding it to your main window using the config method.
Work Step by Step
Here's an example:
import tkinter as tk
root = tk.Tk()
menubar = tk.Menu(root)
filemenu = tk.Menu(menubar, tearoff=0)
filemenu.add_command(label="Open", command=lambda: print("Open"))
filemenu.add_command(label="Save", command=lambda: print("Save"))
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = tk.Menu(menubar, tearoff=0)
editmenu.add_command(label="Cut", command=lambda: print("Cut"))
editmenu.add_command(label="Copy", command=lambda: print("Copy"))
editmenu.add_command(label="Paste", command=lambda: print("Paste"))
menubar.add_cascade(label="Edit", menu=editmenu)
root.config(menu=menubar)
root.mainloop()
This code creates a Tk object that represents the main window, creates a Menu widget to serve as the menu bar, creates two sub-menus for "File" and "Edit", and adds various commands to each sub-menu. Finally, the menu bar is added to the main window using the config method.