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 tk win = 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 certain number of Label
widgets (depending on your monitor's resolution) but will likely not see all 30.
If you have the ability to move the window above the top of your screen (on my Linux machine I can hold Alt and drag the middle of the window upwards...