O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a scrollable frame

There will come a time when writing applications with Tkinter when you will want to add a Scrollbar to the application as a whole, rather than an individual widget (such as the Text widget, which we have already covered). This is not a trivial task, since Tkinter will usually expand itself to show all of its containing widgets, or if the geometry is already set, will simply hide them underneath the bottom border of the window.

Let's take a look at what I mean. Open a new Python script and type the following short snippet:

import tkinter as tkwin = tk.Tk()for _ in range(30):    tk.Label(win, text="big label").pack(pady=20)win.mainloop()

If you run this file you should see a very tall window open up. You will see a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required