'Tkinter FileMenu....not working (no error code)

I am using the following code but cant seem to get a help-menu in the actual window.

Can you see anything in terms of menu when you run the code ? I have tried numerous tkinter templates but nothing as of yet has been successful and it's really perplexing as it must be a problem on my end but I don't know what it is ! My IDE is pycharm and I am not getting any error code.

from tkinter import *
from tkinter import messagebox

ws = Tk()
ws.title("Python Guides")
ws.geometry("300x250")


def about():
    messagebox.showinfo('PythonGuides', 'Python Guides aims at providing best practical tutorials')


menubar = Menu(ws, background='#ff8000', foreground='black', activebackground='white', activeforeground='black')
file = Menu(menubar, tearoff=1, background='#ffcc99', foreground='black')
file.add_command(label="New")
file.add_command(label="Open")
file.add_command(label="Save")
file.add_command(label="Save as")
file.add_separator()
file.add_command(label="Exit", command=ws.quit)
menubar.add_cascade(label="File", menu=file)

edit = Menu(menubar, tearoff=0)
edit.add_command(label="Undo")
edit.add_separator()
edit.add_command(label="Cut")
edit.add_command(label="Copy")
edit.add_command(label="Paste")
menubar.add_cascade(label="Edit", menu=edit)

help = Menu(menubar, tearoff=0)
help.add_command(label="About", command=about)
menubar.add_cascade(label="Help", menu=help)

ws.config(menu=menubar)
ws.mainloop()


Solution 1:[1]

The code is working fine. There must be some issue with your IDE. When I am stuck in these kinds of situations then I check the code either on the replit (web-based ide). if the code works fine on replit then I run the code on my local system using cmd directly. I hope this will help you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vineet Singh