[Tutor] laying out frames

Zubin Wadia zubinw at zapdomain.ca
Mon May 15 21:42:48 CEST 2006


Hello Everyone,

Another basic question in regard to frame layouts with Tkinter.

I want to create a basic quadrant of frames but am not able to follow the
logic to do so, whats the right way or an easier way to control layout of
frames and wigets. A pixel approach would be nice (where by you can
specify pixel locations for a frame or a widget to be located) instead of
specifying arbitary location positions like LEFT, RIGHT, etc and things
moving constantly when you add more widgets or resize windows.

Here's my code bit ...

from Tkinter import *

class App:
	def __init__(self, root):
		fm1= Frame(root, width=200, height=200, bg="blue")
		fm1.pack(side=TOP, anchor= NW)

		fm2 = Frame(root, width=200, height=200, bg="RED")
		fm2.pack(side=TOP, anchor= NW)

		fm3 = Frame(root, width=200, height=200, bg="YELLOW")
		fm3.pack(side=LEFT, anchor= NE)


		fm4 = Frame(root, width=200, height=200, bg="TAN")
		fm4.pack(side=LEFT, anchor=NE)



root = Tk()
root.wm_title("layout")
display = App(root)
root.mainloop

Thanks in advance.
--zubin



More information about the Tutor mailing list