I have these few lines in a class in my program but it doesnt appear. No errors are shown and when i "print(menubar)" and address "0.4.." or "4..." appears

menubar = Menu(master = self.mainGUI)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Exit", command= destroyMethod)
menubar.add_cascade(label="File", menu=fileMenu)

destroy method does work and is existing.

Recommended Answers

All 2 Replies

Maybe this will help ...

# a Tkinter menu example similar to:
# http://effbot.org/tkinterbook/tkinter-application-windows.htm

    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def outer(val):
    """using a closure to pass args"""
    def inner():
    return inner

root = tk.Tk()

# create a menu
menu = tk.Menu(root)

filemenu = tk.Menu(menu)
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="New", command=outer("New"))
filemenu.add_command(label="Open", command=outer("Open"))
filemenu.add_command(label="Exit", command=outer("Exit"))

helpmenu = tk.Menu(menu)
menu.add_cascade(label="Help", menu=helpmenu)
helpmenu.add_command(label="About", command=outer("About"))


I managed to fix it
this was the end code

menubar = Menu(self.mainGUI)
fileMenu = Menu(menubar)
fileMenu.add_command(label="Exit", command= self.destroyMethod)
menubar.add_cascade(label="File", menu=fileMenu)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.