The following is a small python3 script from a web tutorial that demonstrates how to make pulldown menubars using Tkinter.
It is copied directly from https://www.tutorialspoint.com/python3/tk_menu.htm with no changes!
- It works fine when I run it on a raspberry pi (using 3 different IDEs)
BUT when I run it on my Mac (in 2 different IDEs) it just creates the white window and places no menu elements into it.
NOTE that this Mac is able to run other simple Tkinter scripts that I have been making as I try to learn Tkinter... making buttons, popups, no problem.
New Edit: When I go to the macs that this is failing on, and I do:
>>> import tkinter
>>> tkinter._test()
...the test works fine with its little buttons etc, and I get the little window telling me it's v8.5.
What is it about this script that is making the mac choke (and the other computer is not)? Huge thanks!
Here is the tkinter script that fails on the macs:
# !/usr/bin/python3
from tkinter import *
def donothing():
filewin = Toplevel(root)
button = Button(filewin, text="Do nothing button")
button.pack()
root = Tk()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff = 0)
filemenu.add_command(label="New", command = donothing)
filemenu.add_command(label = "Open", command = donothing)
filemenu.add_command(label = "Save", command = donothing)
filemenu.add_command(label = "Save as...", command = donothing)
filemenu.add_command(label = "Close", command = donothing)
filemenu.add_separator()
filemenu.add_command(label = "Exit", command = root.quit)
menubar.add_cascade(label = "File", menu = filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label = "Undo", command = donothing)
editmenu.add_separator()
editmenu.add_command(label = "Cut", command = donothing)
editmenu.add_command(label = "Copy", command = donothing)
editmenu.add_command(label = "Paste", command = donothing)
editmenu.add_command(label = "Delete", command = donothing)
editmenu.add_command(label = "Select All", command = donothing)
menubar.add_cascade(label = "Edit", menu = editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label = "Help Index", command = donothing)
helpmenu.add_command(label = "About...", command = donothing)
menubar.add_cascade(label = "Help", menu = helpmenu)
root.config(menu = menubar)
root.mainloop()
#! /usr/bin/python3