THE BELOW CODE DOES NOT WORK ON MY MacBook Air 2019:-
from tkinter import *
root = Tk()
root.geometry("733x566")
root.title("Pycharm")
def myfunc():
print("PYTHON IS THE BEST !")
# #Use these to create a non dropdown menu
# mymenu = Menu(root)
# mymenu.add_command(label="File", command=myfunc)
# mymenu.add_command(label="Exit", command=quit)
# root.config(menu=mymenu)
mainmenu = Menu(root)
m1 = Menu(mainmenu, tearoff=0)
m1.add_command(label="New project", command=myfunc)
m1.add_command(label="Save", command=myfunc)
m1.add_separator()
m1.add_command(label="Save As", command=myfunc)
m1.add_command(label="Print", command=myfunc)
root.config(menu=mainmenu)
mainmenu.add_cascade(label="File", menu=m1)
m2 = Menu(mainmenu, tearoff=0)
m2.add_command(label="Cut", command=myfunc)
m2.add_command(label="Copy", command=myfunc)
m2.add_separator()
m2.add_command(label="Paste", command=myfunc)
m2.add_command(label="Find", command=myfunc)
root.config(menu=mainmenu)
mainmenu.add_cascade(label="Edit", menu=m2)
root.mainloop()
This doesn’t give me an error(THANK GOD!),but doesn’t give me the desired output(WHAT THE HECK!)
Hi there - welcome to the forums.
What were you expecting to happen with that code? Only asking because, if I run it, whenever I click any of the menu options I get the expected output in the terminal:
Edit: I wonder if what you meant to do was this?