I found an answer thanks to the hint from @acw1668;
I adjusted the <Configure>
command to check the size of the scrollregion
and compare it to the parent ScrollableFrame
class window. If it is smaller, I change the scroll region to be the size of the ScrollableFrame
.
Here are the adjustments I made to my class, including changing the window anchor to sit at the top left of the frame;
class ScrollableFrame(ttk.Frame):
"""
"""
def __init__(self, parent):
"""
"""
...
self.scrollableFrame.bind("<Configure>", self.update_scroll_region)
...
self.canvas.create_window((0, 0), window=self.scrollableFrame, anchor='nw')
def update_scroll_region(self, event):
bbox = self.canvas.bbox('all')
sfHeight = self.winfo_height()
if (bbox[3] - bbox[1]) < sfHeight:
newBbox = (bbox[0], 0, bbox[2], sfHeight)
self.canvas.configure(scrollregion=newBbox)
else:
self.canvas.configure(scrollregion=self.canvas.bbox("all"))