In an effort to learn Tkinter, I've put together the program below. When I leave the button out of the interface the two frames are the same size when displayed. However, if the button is placed in either frame, the frame with the button shrinks.
import tkinter as tk def main(): main_win = tk.Tk() main_win.title('just playing around') main_win.geometry('350x450') main_win.rowconfigure(0, weight=1) main_win.rowconfigure(1, weight=1) main_win.columnconfigure(0, weight=1) main_win.columnconfigure(1, weight=1) main_win.columnconfigure(2, weight=1) frm1 = tk.Frame(main_win, bg='red', height=100, width=350) frm1.grid(row=0, sticky='nsew') frm1.rowconfigure(0, weight=1) frm1.rowconfigure(1, weight=1) frm1.rowconfigure(2, weight=1) frm1.columnconfigure(0, weight=1) frm2 = tk.Frame(main_win, bg='green', height=150, width=350) frm2.grid(row=1, sticky='nsew') frm2.rowconfigure(0, weight=1) frm2.rowconfigure(1, weight=1) frm2.rowconfigure(2, weight=1) frm2.columnconfigure(0, weight=1) quit_btn = tk.Button(frm1, bg='lightgrey', text='Quit', command=main_win.destroy) quit_btn.grid(row=1) main_win.mainloop() return 0 if __name__ == '__main__': main()
Why is this happening, and what is needed to keep the frames the same size?
(Also, resizing the window causes the frames to resize vertically, but not horizontally. Why is that happening and how do I make the resizing happen in both directions (or turn it off in both directions)?)