Frames in TK
Jonathan Giddy
jon at dgs.monash.edu.au
Mon Apr 10 21:13:20 EDT 2000
Shah, Navneet declared:
>
>Can anyone let me know the code for making frames in TK. I need to have
>two frames in the window with the top frame should cover 65% of the
>window while the remaining 35% should be covered by the second frame.
For that level of control, use the Tk place command. Alternatively, the Pmw
PanedWidget gives the user more control.
from Tkinter import *
def create_frames(master):
# relief and borderwidth arguments make frames visible
frame1 = Frame(master, relief='sunken', borderwidth=2)
frame2 = Frame(master, relief='sunken', borderwidth=2)
frame1.place(relx=0, rely=0, relwidth=1, relheight=0.65)
frame2.place(relx=0, rely=0.65, relwidth=1, relheight=0.35)
# put something in the frames
label1 = Label(frame1, text="Hello")
label1.grid(row=0, column=0)
label2 = Label(frame2, text="World!")
label2.grid(row=0, column=0)
root = Tk()
create_frames(root)
root.mainloop()
More information about the Python-list
mailing list