Python GUI with Tkinter - 9 - Creating Drop Down Menus
Why Stack Overflow recommends it
Stack Overflow users cite it as the tutorial they were following when their own Tkinter menu code failed, often because of Python version differences, typos, or Mac behaviour.
Recommended by 0 people across 0 different months, 2016 to 2020.
What it is
Episode 9 of thenewboston's Python Tkinter tutorial series, a screen-recorded walkthrough of building drop-down menus (File and Edit menus with commands and separators) in a Tkinter window. It is aimed at complete beginners and was recorded in 2014 on Windows.
What people said
Cites TheWoollySheep · 2016-10 · Stack Overflow · on “broken dropdown menu code”
I was following [this video] a tutorial for doing a drop-down menu in a gui. In the video the code works but i can't get mine too, I think it may have something to do with different python versions. from tkinter import * def doNothing(): print ("ok ok i won't...") root = Tk() menu = Menu(root) roo.config(menu=menu) subMenu = Menu(menu) menu.add_cascade(label="File", menu=subMenu) subMenu.add_command(label="New Project..."), comand=doNothing subMenu.add_command(label="New"), comand=doNothing subMenu.add_separator() subMenu.add_command(label="Exit", command=doNothing) editMenu = Menu(menu) menu.add_cascade(label="Edit", menu=editMenu) editMenu.add_command(label="Redo", comand=doNothing) root.mainlo
Cites gmonz · 2017-03 · Stack Overflow · on “Is there a way to show the menu bar inside an application window on a Mac?”
I was following a tutorial [this video] and received different results when doing exactly what was said. I want the menu bar to show up inside the actual tkinter application window like it does on the tutorial. He is using Windows. It is instead showing up on the actual top menu bar of the computer. I am using a Mac if that makes a difference. Is there a way to fix this? This is my code: from tkinter import * def doNothing(): label1 = Label(root, text="Doing nothing") label1.pack() root = Tk() mainmenu = Menu(root) root.config(menu=mainmenu) filemenu = Menu(mainmenu) mainmenu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New Project", command=doNothing) filemenu.add_command
Cites Ajay M · 2019-01 · Stack Overflow · on “add_cascade() missing 1 required positional argument: self (Python: Tkinter error)”
I am trying to learn how to make a basic GUI in Python with menus. I have been following a tutorial from 2014 ( [this video] ), but it seems that several things have been updated since the tutorial was published. While I have found workarounds for several of my issues there were a couple I could not figure out. The biggest issue of which is a "TypeError: add_cascade() missing 1 required positional argument: 'self'" error. Everything I can find seems to have similar syntax to my code however I cannot seem to run it. I think it is probably a difference in python versions ( I am running python 3.7 ) though it is also likely I am just missing something in the tutorial. import tkinter def doNothing():
Cites Parzalai · 2020-08 · Stack Overflow · on “Menu Bar not appearing on Tkinter GUI”
I'm new to Tkinter and currently am learning from videos, I'm trying to create a menu bar with a further drop-down menu with some options and a separator, they won't have any function as I'm just trying to achieve that goal before adding onto it. Here's the code: from tkinter import * def donothing(): print('Done') root = Tk() menuTop = Menu(root) # this is a blank menu bar at the top root.config(menu=menuTop) # configures the menu feature, and assigns it to the Menu value submenuDown = Menu(menuTop) # this is a meta menu that *will* drop down menuTop.add_cascade(label='File', menu=subMenu) # assigns drop down menu to submenu def submenuDown.add_command(label='Yes...', command=donothing) sub