Creating horizontal and vertical scrollbars
In Tkinter, geometry managers take all the necessary space to fit all the widgets in their parent container. However, if the container has a fixed size or exceeds the screen's size, there will be a region that will not be visible to users.
Scroll bar widgets are not automatically added in Tkinter, so you must create and lay them out as any other type of widget. Another consideration is that only a few widget classes have the configuration options that make it possible to connect them to a scrollbar.
To work around this, you will learn to take advantage of the flexibility of the Canvas widget to make any container scrollable.
Getting ready
To demonstrate the combination of the Canvas
and Scrollbar
classes to create a resizable and scrollable frame, we will build an application that dynamically changes its size by loading an image.
When the Load image
button is clicked, it removes itself and loads an image into the Canvas
that is larger than the scrollable...