[Tkinter-discuss] Layout problem using grid manager

pellegrini pellegrini at ill.fr
Wed Sep 3 15:26:40 CEST 2008


Hello Everybody,

I have a problem using the grid manager.

I would expect the following code to place:
    -button 1 and 2 at the top of the left frame
    -button 3 at the bottom of the left frame
    -button 4 at the top of the right frame
Instead, it places:
    -button 1, 2, 3 at the center of the left frame
    -button 4 at the center of the right frame.

Would you have any idea how what is wrong and how to solve this using 
the grid manager (and only this one) ?

#####################################################"
import Tkinter as tk
 
root=tk.Tk()
 
root = tk.Toplevel()

frame1=tk.Frame(root,bg='black',width=200,height=300)
frame1.grid(row = 0, column = 0)
frame1.grid_propagate(0)

button1 = tk.Button(frame1,text='button 1')
button1.grid(padx=3,pady=3, sticky = N)

button2 = tk.Button(frame1,text='button 2')
button2.grid(padx=3,pady=3, sticky = N)

button3 = tk.Button(frame1,text='button 3')
button3.grid(padx=3,pady=3, sticky = S)

frame2=tk.Frame(root,bg='white',width=200,height=300)
frame2.grid(row = 0, column = 1)
frame2.grid_propagate(0)

button4 = tk.Button(frame2,text='button 4')
button4.grid(padx=3,pady=3, sticky = N)
 
root.mainloop()
#############################################

thanks a lot

bye

Eric



More information about the Tkinter-discuss mailing list