Python Forum
[Tkinter] How to create scrollable frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How to create scrollable frame
#8
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.
        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_forget
Why 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.
Reply


Messages In This Thread
How to create scrollable frame - by mandiatutti - Aug-06-2021, 04:09 PM
RE: How to create scrollable frame - by deanhystad - Aug-06-2021, 06:38 PM
RE: How to create scrollable frame - by mandiatutti - Aug-06-2021, 07:15 PM
RE: How to create scrollable frame - by deanhystad - Aug-06-2021, 07:28 PM
RE: How to create scrollable frame - by mandiatutti - Aug-06-2021, 07:48 PM
RE: How to create scrollable frame - by deanhystad - Aug-07-2021, 05:39 AM
RE: How to create scrollable frame - by mandiatutti - Aug-07-2021, 06:58 AM
RE: How to create scrollable frame - by deanhystad - Aug-07-2021, 03:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] PyQt5 drawing on scrollable area HeinKurz 3 1,350 Mar-28-2023, 12:58 PM
Last Post: Axel_Erfurt
  [Tkinter] Scrollable buttons with an add/delete button Clich3 5 3,476 Jun-16-2022, 07:19 PM
Last Post: rob101
Question [Tkinter] Scrollable Treeview: change behavior of Prior/Next keys? RockDoctor 2 3,228 Apr-10-2021, 05:40 PM
Last Post: RockDoctor
  Scrollable big image in a window (TKinter) Prospekteur 3 4,516 Sep-14-2020, 03:06 AM
Last Post: Larz60+
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 9,043 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 11,176 Apr-18-2019, 05:36 PM
Last Post: atlass218
  [Tkinter] Fixate graphs on scrollable canvas janema 6 5,449 Apr-12-2019, 03:57 PM
Last Post: Larz60+
  [Tkinter] ListBox not contained or scrollable kellykimble 6 5,199 Apr-05-2018, 11:59 AM
Last Post: Larz60+
  [Tkinter] Frame size only works if frame is empty(Solved) Tuck12173 7 6,482 Jan-29-2018, 10:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020