Can someone please tell me why my menubar does not show up?

#!/usr/bin/env python
from Tkinter import *


class Application(Frame):
    
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.master.rowconfigure(0, weight=1)
        self.master.columnconfigure(0, weight=1)
        self.master.title('Test Menu')
        self.createMenu(master)
        #self.createShell()
        
    def createMenu(self, master):
        menubar = Menu(master)
        master.config(menu=menubar)
        
        loadmenu = Menu(menubar)
        loadmenu.add_command(label='Load', command=self.load)
        loadmenu.add_command(label='Save', command=self.save)
        loadmenu.add_separator()
        loadmenu.add_command(label='Quit', command=self.quit)
        #master.grid()

    def createShell(self):
        frame = Frame(width=400, height=300)
        frame.grid() 
    
    def load(self):
        pass
    
    def save(self):
        pass
    
    def quit(self):
        pass
    

root = Tk()
app = Application(master=root)
app.mainloop()

There are two problems that I can see. It should be "root.mainloop" and there is no config statement for load menu so only the empty "menubar" is displayed. Also, note the inconsistent use of master and self.master. I did not test with any of the commented lines included. If they contain other problems that you can not solve, post back.

from Tkinter import *
 
class Application(Frame):
 
    def __init__(self, master=None):
#        Frame.__init__(self, master)
#        self.master.rowconfigure(0, weight=1)
#        self.master.columnconfigure(0, weight=1)
#        self.master.title('Test Menu')
        self.createMenu(master)
        #self.createShell()
 
    def createMenu(self, master):
#        menubar = Menu(master)
 
        loadmenu = Menu(master)
        loadmenu.add_command(label='Load', command=self.load)
        loadmenu.add_command(label='Save', command=self.save)
        loadmenu.add_separator()
        loadmenu.add_command(label='Quit', command=master.quit)
        #master.grid()
        master.config(menu=loadmenu)
 
    def createShell(self):
        frame = Frame(width=400, height=300)
        frame.grid() 
 
    def load(self):
        print "load called"
 
    def save(self):
        print "save called"
 
    ## this function is not being used by the code as it is now
    def quit(self):
        pass
 
 
root = Tk()
app = Application(master=root)
root.mainloop()
Be a part of the DaniWeb community

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