[Tutor] laying out a menu widget inside a frame

Michael Lange klappnase at freenet.de
Fri May 12 09:41:24 CEST 2006


On Thu, 11 May 2006 15:03:53 -0400 (EDT)
"Zubin Wadia" <zubinw at zapdomain.ca> wrote:

> Hello All,
> 
> from Tkinter import *
> 
> class App:
>     #create a frame
>     def __init__(self, master):
>         frame = Frame(master, bg="LIGHTBLUE", relief=RIDGE, bd=3)
>         frame.pack(side=TOP, ipadx=15, ipady=15, fill=X)
> 
>         ##create dropdown menu
> 
>         menubar = Menu(frame)
> 
>         filemenu = Menu(menubar)
>         menubar.add_cascade(label="File", menu=filemenu)
>         filemenu.add_command(label="New")
> 
>         root.config(menu=menubar) ##edit
> 
> root = Tk()
> root.minsize(100,100)
> app = App(root)
> root.mainloop()
> 
> This works great but I can't get the dropdown menu to layout in the frame
> widget instead of the root. I tried frame.config() in the ##edit line but
> I don't think there is a config method for the frame widget, it errors
> out.
> 

Hi Zubin,

there is a typo in your code, it should be

    master.config(menu=menubar)

but this does not seem to be your problem?
If you just want the menu to be inside the "lightblue", "RIDGE" part of the window, try:

    root.config(relief=RIDGE, bg="lightblue", bd=3)

and relief="flat", bg="lightblue" on the frame.

I hope this helps

Michael



More information about the Tutor mailing list