I have a Tkinter class with a grid in it, each of the grid rows should be the same weight as stated in the row configuration and the content of the grid should not affect the grid dimensions as I turned propagation off.
This works fine as long as I have empty frames with background colours in the grid but as soon as I add a button to the top grid row the row increases in size compared to the other ones by about exactly the height of the button itself. The code is as follows:
class MainMenuPage(tkinter.Frame):
def __init__(self,parent,controller):
tkinter.Frame.__init__(self,parent)
self.controller=controller
self.columnconfigure(0,weight=1)
self.rowconfigure(0,weight=1)
self.rowconfigure(1,weight=1)
self.rowconfigure(2,weight=1)
self.rowconfigure(3,weight=1)
self.grid_propagate(0);
self.color0=tkinter.Frame(self,bg="#bd1e2b")
self.color0.grid(column=0,row=0,sticky="nesw")
self.color1=tkinter.Frame(self,bg="#1e1ebd")
self.color1.grid(column=0,row=1,sticky="nesw")
self.color2=tkinter.Frame(self,bg="#1ebd48")
self.color2.grid(column=0,row=2,sticky="nesw")
self.color3=tkinter.Frame(self,bg="#bdb81e")
self.color3.grid(column=0,row=3,sticky="nesw")
image=Image.open("/path/settingsIcon.png")
image=image.resize((54,54),Image.ANTIALIAS)
self.settingsIcon=ImageTk.PhotoImage(image)
self.settingsButton=tkinter.Button(self,compound=tkinter.TOP,width=54,height=54,image=self.settingsIcon,command=lambda:self.controller.showPage("valveMain"))
self.settingsButton.grid(column=0,row=0,sticky="ne")
How do I prevent the grid from changing size when the button is added ?