Hello,
im currently working on my major work and im up to the stage where i want to implement a cascade menu into my window.
i have differnt buttons on my window but i want the food options to pop down in a cascade menu and not a check menu, i have succesfully created the cascade menu but am having trouble changing it into a child from a parent,
## Screen design draft for major project
## Filename: majorProjectDesignDraft20090222.pyw
##
from Tkinter import *
class Application(Frame):
def __init__(self, master=None):
self.master = master=None
self.menubar = Menu(self.master)
Frame.__init__(self)
self.grid()
self.createQuit()
self.createHelp()
self.createRegister()
self.createHeader()
self.createSpace()
self.createMenu()
self.createOrder()
self.createCascade()
menubar = Menu(self.child)
def createHeader(self):
top=self.winfo_toplevel()
top.rowconfigure(0,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.columnconfigure(0, weight=1)
self.heading = Label ( self, text="Major Project Draft",relief=FLAT, font=('Arial', 30))
self.heading.grid(row=0, column=0)
def createSpace(self):
top=self.winfo_toplevel()
top.rowconfigure(1,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(1, weight=1)
self.columnconfigure(0, weight=1)
self.heading = Label ( self, text="",relief=FLAT, font=('Arial', 20))
self.heading.grid(row=1, column=0)
def createHelp(self):
top=self.winfo_toplevel()
top.rowconfigure(2,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(2, weight=1)
self.columnconfigure(0, weight=1)
self.button = Button ( self, text="HELP",relief=FLAT, font=('Arial', 20))
self.button.grid(row=2, column=0)
def createRegister(self):
top=self.winfo_toplevel()
top.rowconfigure(3,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(3, weight=1)
self.columnconfigure(0, weight=1)
self.button = Button ( self, text="REGISTER AS MEMBER",relief=FLAT, font=('Arial', 20))
self.button.grid(row=3, column=0)
## def createMenu(self):
## top=self.winfo_toplevel()
## top.rowconfigure(4,weight=1)
## top.columnconfigure(0, weight=1)
## self.rowconfigure(4, weight=1)
## self.columnconfigure(0, weight=1)
## self.button = Button ( self, text="FOOD MENU",font=('Arial', 20))
## self.button.grid(row=4, column=0,
## sticky=N+S+E+W)
def createOrder(self):
top=self.winfo_toplevel()
top.rowconfigure(5,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(5, weight=1)
self.columnconfigure(0, weight=1)
self.button = Button ( self, text="ORDER FOOD",relief=FLAT, font=('Arial', 20,))
self.button.grid(row=5, column=0)
def createQuit(self):
top=self.winfo_toplevel()
top.rowconfigure(7,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(7, weight=1)
self.columnconfigure(0, weight=1)
self.quit = Button ( self, text="QUIT", command=self.quit,relief=FLAT, font=('Arial', 20))
self.quit.grid(row=7, column=0)
def createMenu(self):
self.mb = Menubutton ( self, text='FOOD MENU',
relief=FLAT, font=('Arial', 20))
top=self.winfo_toplevel()
top.rowconfigure(6,weight=1)
top.columnconfigure(0, weight=1)
self.rowconfigure(6, weight=1)
self.columnconfigure(0, weight=1)
self.mb.grid(row=6, column=0)
self.mb.menu = Menu (self.mb, tearoff=0 )
self.mb['menu'] = self.mb.menu
self.meatVar = IntVar()
self.seafoodVar = IntVar()
self.pastaVar = IntVar()
self.vegVar = IntVar()
self.dessertsVar = IntVar()
self.drinksVar = IntVar()
self.mb.menu.add_checkbutton ( label='Meat',
variable=self.meatVar )
self.mb.menu.add_checkbutton ( label='Seafood',
variable=self.seafoodVar )
self.mb.menu.add_checkbutton ( label='Pasta',
variable=self.pastaVar )
self.mb.menu.add_checkbutton ( label='Vegitarian',
variable=self.vegVar )
self.mb.menu.add_checkbutton ( label='Desserts',
variable=self.dessertsVar )
self.mb.menu.add_checkbutton ( label='Beverages',
variable=self.drinksVar )
def createCascade(self, child=0):
self.child = child
self.menubar = Menu(self.child)
self.casmenu = Menu(self.menubar)
self.casmenu.choices = Menu(self.casmenu)
self.casmenu.choices.wierdones = Menu(self.casmenu.choices)
self.casmenu.choices.wierdones.add_command(label='A')
self.casmenu.choices.wierdones.add_command(label='B')
self.casmenu.choices.wierdones.add_command(label='C')
self.casmenu.choices.wierdones.add_command(label='D')
self.casmenu.choices.add_command(label='A')
self.casmenu.choices.add_command(label='B')
self.casmenu.choices.add_command(label='C')
self.casmenu.choices.add_command(label='D')
self.casmenu.choices.add_command(label='E')
self.casmenu.choices.add_command(label='F')
self.casmenu.choices.add_cascade(label='G',
menu=self.casmenu.choices.wierdones)
self.casmenu.add_cascade(label='Scripts',
menu=self.casmenu.choices)
self.unused = Menu(self.menubar)
self.menubar.add_cascade(label="Cascade Menu", menu=self.casmenu)
self.top = Toplevel(menu=self.menubar, width=500, relief=RAISED,
borderwidth=2)
app = Application()
app.master.title("Major Project Sample Screen")
app.mainloop()
any help would be greatly appreciated
RC