Python Tkinter Grid issue - user error?
Question: I am trying to create a basic layout for a Python gui using Tkinter.

    
    
    #!/usr/bin/env python
    from Tkinter import *
    
    #create root
    root = Tk()
    
    banner = Frame(root, width=500)
    body = Frame(root, width=500)
    banner.grid()
    body.grid()
    
    
    bannercontent = Label(banner, bg="Green", text="Green").grid(row=0, column=0)
    bannerbuttons = Label(banner, bg="Red", text="Red").grid(row=0, column=1)
    bodycontent = Label(body, bg="Blue", text="Blue").grid(row=1, column=0, columnspan=2, sticky=E+W)
    root.mainloop()
    

However with the above, the blue label is not expanding to fill the 2 columns
as I'd wish, i.e. fill the space under Green and Red. What am I doing wrong
please?

Example here <http://imgur.com/nGWQX9y>

![example](http://i.stack.imgur.com/UPjQ5.png)

Thank you in advance


Answer: You have a few things wrong with your code. First, you aren't specifying a
`sticky` option, so widgets won't "stick" (ie: grow or shrink) to the edges of
the cell. Your `bodycontent` label is in fact occupying two columns, but the
frame itself isn't expanding to the full width of the main window.

The second problem is that you seem to be assuming that columns span the
entire app. They do not. You have two columns in `banner` because you put a
widget in column 0 and column 1. However, `bodycontent` only has one column
(or, you could say it has two, but the second column is of zero width). The
column sizes in the first frame have no relationship to the columns in the
second frame. Thus, the bottom frame contents won't line up with the top
frame.

A third problem that your code has is that you aren't giving your rows or
columns "weight". The `weight` attribute tells Tkinter how to allocate any
extra space. Since you haven't done that, your GUI does not resize in a
pleasant way when you grow or shrink the window. A good rule of thumb is that
for any given container, at least one row and one column should be given a
non-zero weight.

