Skip to content Skip to sidebar Skip to footer

How To Resize A Scrollable Frame To Fill The Canvas?

The frame that i want to be scrollable is on the left side. I want to expand it to 'fill both'. import tkinter as tk from tkinter import * class Example(tk.Frame): def __init

Solution 1:

The normal way to do this is to bind the <Configure> event of the canvas to a function that resizes the frame to fit the canvas.

class Example(tk.Frame):
    def __init__(self, root):
        ...
        self.canvas.bind("<Configure>", self.onCanvasConfigure)
        ...

    def onCanvasConfigure(self, event):
        # width is tweaked to account for window borders
        width = event.width - 4
        self.canvas.itemconfigure("self.frame", width=width)
    ...

Post a Comment for "How To Resize A Scrollable Frame To Fill The Canvas?"