views:

31

answers:

2

I am having a bit of trouble with the Tkinter grid() manager. It is spacing the rows too far apart. I have two entry widgets to place, and I need one almost directly under the other. When I place them both on the same row and column, but change the pady option, it places them directly on top of each other. I know there has to be a way to fix this, never had this problem before. Anyone have any ideas to help out with this?

I am using Python 2.6 on Windows XP

+2  A: 

Are these the only 2 widgets? Or is there another widget,in another column, that ismore than one row in height? If so, it should add to it the "rowspan" attribute.

If that is not the case, I suggesttaht for this cell alone (aply to it "row3span 2), you add a Tkinter.Frame widget, and within this Frame, you simply add your desired widgets with the "pack" manager.

So, instead of:

entr1.grid(my_window, row=1, column=1)
entr2.grid(my_window, row=1, column=1)

you do:

frame = Tkinter.Frame(my_window)
entr1 = Tkinter.<Whatever-widget>(Frame, ...)
entr1.pack()
entr2 = Tkinter.<Whatever-widget>(Frame, ...)
entr2.pack()
jsbueno
There are 3 more buttons that I need aligned accross the bottom of the window. The reason I need to use the grid() manager is because the widgets are placed on top of a .GIF image.
Zachary Brown
Here, I will pastebin my code: http://pastebin.com/dNrdakHB
Zachary Brown
|Whatverer you are trying, youshould not try to put moret han one widget things on the same grid cell (same row and column). Undo that. Create a cell with colspan=3, fill it with a frame, and use grid or pack to re-distribute idgets inside there if you need.
jsbueno
+2  A: 

Don't place them in the same row and column; place the upper in a row, and the lower in row+1, both in the same column. That does the trick.

Note that the grid manager does not need to have all rows and columns filled with widgets; it ignores empty rows and columns.

ΤΖΩΤΖΙΟΥ