I'm trying to create a scrollable widget using grid. The scrollbars are working but for some reason the inner frame is not stretching to fill the canvas.
Here is a simple (not) working example, sans the scrollbars.
import tkinter as tk
class TestFrame(tk.Frame):
def __init__(self, master=None, cnf=None, **kw):
super().__init__(master=master, cnf=cnf, **kw)
self.grid_columnconfigure(0, weight=1)
self.grid_rowconfigure(0, weight=1)
self.canvas = tk.Canvas(self, background='red')
self.canvas.grid(row=0, column=0, sticky=tk.NSEW)
self.canvas.grid_columnconfigure(0, weight=1)
self.canvas.grid_rowconfigure(0, weight=1)
self.inner = tk.Frame(self.canvas, background='blue')
self.inner.grid(row=0, column=0, sticky=tk.NSEW)
self.canvas.create_window(0, 0, anchor=tk.NW, window=self.inner)
if __name__ == "__main__":
window = tk.Tk()
window.geometry('500x500')
window.grid_columnconfigure(0, weight=1)
window.grid_rowconfigure(0, weight=1)
testFrame = TestFrame(window)
testFrame.grid(row=0, column=0, sticky=tk.NSEW)
window.mainloop()
When you run it, you can see that the red canvas fills the entire window but the blue frame is nowhere to be seen. Even when content is added to the frame, it only stretches to accommodate the child widgets.
What am I not understanding about tkinter's grid layout manager?
Thanks in advance for your help.