Aug-07-2021, 03:34 PM
(This post was last modified: Aug-07-2021, 03:34 PM by deanhystad.)
You don't call super().__init__() or tk.Frame.__init__(self) in your ScrollableFrame.__init__() method. I noticed this when I tried to bind a function to the <configure> event. The frame doesn't have a window, so the request failed. There's probably many oddities occurring because your Scrollable frame is only partially a frame.
What is the purpose of the master_frame? You need a frame in which to place the canvas and scrollbars, but this should be the ScrollableFrame (self). Get rid of the master_frame and make the ScrollableFrame the parent of the canvas. This will clean up a lot of ugly in your code.
You should not have to specify hscroll or vscroll. If the scrolling window is wider than the viewport you should display a horizontal scrollbar. If the scrolling window is taller than the viewport you should display a vertical scrollbar. If your scrolling window is smaller than the viewport there should be no scrollbars and you might want to expand the scrolling window to fill the viewport.
What is the purpose of the master_frame? You need a frame in which to place the canvas and scrollbars, but this should be the ScrollableFrame (self). Get rid of the master_frame and make the ScrollableFrame the parent of the canvas. This will clean up a lot of ugly in your code.
self.pack = self.master_frame.pack # Yuck! self.grid = self.master_frame.grid self.place = self.master_frame.place self.pack_forget = self.master_frame.pack_forget self.grid_forget = self.master_frame.grid_forget self.place_forget = self.master_frame.place_forgetWhy is your ScrollableFrame height so large? The ScrollableFrame height should be the height of what is currently the master_frame.
You should not have to specify hscroll or vscroll. If the scrolling window is wider than the viewport you should display a horizontal scrollbar. If the scrolling window is taller than the viewport you should display a vertical scrollbar. If your scrolling window is smaller than the viewport there should be no scrollbars and you might want to expand the scrolling window to fill the viewport.