[Tutor] Tkinter query?

Dave S pythontut at pusspaws.net
Thu Jul 14 19:53:40 CEST 2005


>
> Frames are used to help with positioning other widgets, yes. They are
> also used
> to affect how the application looks: you can change the background
> colour of
> Frames, and also the border (to make them look like they are sticking
> out, for
> example). But you can (and frequently will) put Frames inside other
> Frames.
>
> Example:
>
> from Tkinter import *
>
> tk = Tk()
> tk.config(background='pink')
> tk.geometry('400x400')
>
> frame1 = Frame(tk, background='blue')
> frame1.pack(side=LEFT, padx=15, pady=15, expand=True, fill=BOTH)
>
> frame2 = Frame(tk, background='green', borderwidth=3, relief=RAISED)
> frame2.pack(side=LEFT, padx=15, pady=15, expand=True, fill=BOTH)
>
> frame3 = Frame(frame1, background='red', borderwidth=3, relief=SUNKEN)
> frame3.pack(side=TOP, padx=15, pady=15, expand=True, fill=BOTH)
>
> frame4 = Frame(frame1, background='white', borderwidth=3, relief=GROOVE)
> frame4.pack(side=TOP, padx=15, pady=15, expand=True, fill=BOTH)
>
> label1 = Label(frame4, text='Hello world!')
> label1.pack(expand=True)
>
> tk.mainloop()
>
Thank you, that has clarified a few points but raised a query.
tk.geometry('400x400') does not appear to have any effect on its size
when the window is drawn, the window is always the same size and short
of maximizing it to full screen it is not adjustable.

Just a minor query but interesting

Dave


More information about the Tutor mailing list