I am in the process of learning Tkinter and while building general windows, frames, and all the widgets to get a feel for the interface, I ran into an issue that I can't figure out why it is behaving as is.
I created a root window, with 3 frames and each frame has a button. The purpose of this exercise was to make sure that the frames and root window would stretch properly.
The window and the frames do, but I noticed that the button on the first frame stays centered but the other buttons on frame 2 and 3 do not.
I am just trying to understand why this is happening.
Here is the code:
import tkinter as tk
MW = tk.Tk()
MW.title("TK Main Window")
MW.config(bg='#8FBC8F',padx=5,pady=5,relief=tk.RIDGE,bd=3)
FRM1 = tk.Frame(MW,bd=3,relief=tk.RIDGE,bg='#1E90FF',padx=10,pady=10)
FRM1.grid(row=0,column=0,sticky=tk.E + tk.W + tk.N + tk.S,padx=5,pady=5)
FRM1.rowconfigure(0,weight=1)
FRM1.columnconfigure(0,weight=1)
bt1 = tk.Button(FRM1, text="FRM1 button")
#bt1.grid(row=0,column=0,sticky=tk.W)
bt1.grid()
FRM2 = tk.Frame(MW,bd=3,relief=tk.RIDGE,bg='#B0C4DE',padx=10,pady=10)
FRM2.grid(row=1,column=0,sticky=tk.E + tk.W + tk.N + tk.S,padx=5,pady=5)
FRM2.rowconfigure(1,weight=1)
FRM2.columnconfigure(0,weight=1)
bt2 = tk.Button(FRM2, text="FRM2 button")
bt2.grid()
FRM3 = tk.Frame(MW,bd=3,relief=tk.RIDGE,bg='#FFE4B5',padx=10,pady=10)
FRM3.grid(row=2,column=0,sticky=tk.E + tk.W + tk.N + tk.S,padx=5,pady=5)
FRM3.rowconfigure(2,weight=1)
FRM3.columnconfigure(0,weight=1)
bt3 = tk.Button(FRM3, text="FRM3 button")
bt3.grid()
MW.rowconfigure(0,weight=1)
MW.rowconfigure(1,weight=1)
MW.rowconfigure(2,weight=1)
MW.columnconfigure(0,weight=1)
MW.mainloop()
Here is how it looks:
