Menu
You don't need to pack menus, but you need to place them on a window:
menu = Menu(root)
and then configure the window with the menu:
root.config(menu=menu)
use menu.add_cascade() to create horizontal top-level menu items, and add_command to place clickable vertical items
menu = Menu(root)
and then configure the window with the menu:
root.config(menu=menu)
use menu.add_cascade() to create horizontal top-level menu items, and add_command to place clickable vertical items
from tkinter import * from tkinter import messagebox from tkinter.filedialog import askopenfilename import subprocess from platform import system as platform root = Tk() def new_game(): messagebox.showinfo("New Game", "New Game") def save_game(): filename = askopenfilename() #returns an absolute path to the file messagebox.showinfo("filename", filename) def about(): messagebox.showinfo( "About this page", "About this page") menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="Game", menu=filemenu) filemenu.add_command(label="New", command=new_game) filemenu.add_command(label="Save", command=save_game) filemenu.add_separator() filemenu.add_command(label="Exit", command=root.quit) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=about) #there is a tkinter bug on MacOS that doesn't make the menu work until the #pyton looses focus and then refocuses #the code below focuses the application on finder and then back on python #as a workaround if platform() == 'Darwin': subprocess.call(["/usr/bin/osascript", "-e", 'tell app "Finder" to set frontmost of process "Finder" to true']) subprocess.call(["/usr/bin/osascript", "-e", 'tell app "Finder" to set frontmost of process "python" to true']) root.mainloop()