python 3.x - Tkinter Frame enlarges when adding widgets -
i'm writing simple tkinter app has main frame 2 smaller frames on sides, so:
root = tk.tk() root.title("myapp") root.rowconfigure(0,weight=1) root.columnconfigure(0,weight=1) root.columnconfigure(1,weight=4) root.columnconfigure(2,weight=1) frame1 = tk.frame(root) frame1.grid(row=0,column=0,sticky='nsew') button1 = tk.button(frame1,relief=tk.flat,text="button") button1.grid() frame2 = tk.frame(root) frame2.grid(row=0,column=1,sticky='nsew') button2 = tk.button(frame2,relief=tk.flat,text="button") button2.grid() frame3 = tk.frame(root) frame3.grid(column=2,row=0,sticky='nsew') button3 = tk.button(frame3,relief=tk.flat,text="button") button3.grid() but if add more widgets 1 of these frames:
button4 = tk.button(frame3,relief=tk.flat,text="button") button4.grid(row=0,column=1) button5 = tk.button(frame3,relief=tk.flat,text="button") button5.grid(row=0,column=2) then frame3 enlarges (instead of shrinking, understand should do), ignoring 1-to-4 specification of columnconfigure. i've been googling crazy found no answer, ideas more welcome. thanks.
update: answers. wanted add screenshot don't have enough reputation post image. if weights don't prevent column being overexpanded, how can make sure frames keep initial proportions despite how many widgets add them. should turn grid_propagate off or there better way?
each frame size need to contain widgets. weights determine allocation of space if stretch window. determine rate @ different widgets compress if shring window. in case, second frame looses space 4x faster.
Comments
Post a Comment