4

I want to make a whole column of various widgets scrollable in a Tkinter GUI, like so: interface example

Tkinter can only attach scrollbars to certain widgets, of which, frames are not included. Making a scollable column is a common practice in interfaces, and there should be a simple solution, but so far, all I have been able to find is this hacky example of a scrollable frame, using a canvas widget. A similar hacky solution was used in a similar stack overflow question.

Is there a commonly accepted way in Tkinter to make a column, or a group of widgets, that is scrollable?

Community
  • 1
  • 1
Cypress Frankenfeld
  • 2,317
  • 2
  • 28
  • 40

1 Answers1

1

The solution using the canvas is the commonly accepted way to solve this problem. It's really not all that hacky, and the end result can be indistinguishable from having a native scrolling container widget.

If you're making a single column, another option is to use a text widget, and use the widget's ability to embed other widgets. Insert a widget, then insert a newline, insert another widget, etc. You then get the scrolling ability for free. The only thing you need to worry about is configuring the width of the embedded windows, which isn't too hard to do.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Bryan, I noticed there is an issue with not being able to scroll via the scroll wheel on the mouse when using the canvas solution. That's one of the issues I have with it. Is there a common workaround for that as well, or would you recommend going with embedding widgets inside a text widget? – Cypress Frankenfeld May 30 '13 at 17:00
  • @CypressFrankenfeld: I don't remember the trick to getting the mouse wheel working. It probably has something to do with the fact the cursor is over a frame rather than over the canvas. You can always create your own bindings to the mouse wheel. – Bryan Oakley May 30 '13 at 17:18
  • 1
    I see. Is there any way to implement mouse wheel scrolling to work like it does throughout the rest of the system? I feel like binding the mouse wheel to events isn't going to feel very native for someone using a touchpad with two fingers, for example. : / – Cypress Frankenfeld May 30 '13 at 17:28