KJN This category page is intended as a reference for scrollable widgets and scrolled frames.
A scrollable widget has commands xview and yview, and options -xscrollcommand and -yscrollcommand, for interaction with scrollbars.
A scrolled frame is a megawidget that:
- is designed to hold a scrollable widget
- combines scrollbars and frames, typically with optional mapping of scrollbars and automapping (unmapping of a scrollbar when the scrollable widget is small enough to be entirely visible)
- includes code for the combination of the scrollable widget commands and options mentioned above with the scrollbars of the scrolled frame.
The Tk text and canvas widgets are scrollable. The frame and toplevel widgets are not scrollable, but it is often useful to add scrolling when the contents of a frame or toplevel are too large to be displayed. Several packages provide megawidgets that add scrolling to a frame or toplevel, using one of the following techniques:
- Using the place geometry manager to map one frame inside a toplevel or another frame, so that only part of the first frame is visible.
- Using the canvas command create to map the frame as a canvas item.
- Using the text command window to map the frame as an embedded window in a text widget.
Recommended Packages
Many Tcl/Tk packages provide scrollable frames and scrolled windows. The packages in this list are currently maintained, and have high quality documentation and examples.
- Scrollutil provides scrollutil::scrollableframe and scrollutil::scrollarea commands. It has further commands such as scrollutil::scrollsync which scrolls multiple widgets simultaneously. Now included in tklib, and also available from https://www.nemethi.de/
- BWidget provides ScrollableFrame and ScrolledWindow widgets. Example code is at ScrolledWindow.
- Slab, a Snit port of BWidget, provides the same widgets.
Other Packages
These packages are not currently maintained, but may work perfectly well (please add recommendations or other comments).
- tix provides tixScrolledWindow which combines the functionality of a scrollable frame and a scrolled window. (Unmaintained since 2008.)
- incr widgets (= iwidgets) provides iwidgets::scrolledframe which combines the functionality of a scrollable frame and a scrolled window. (Not fully maintained since 2018.)
- scrodget (Unmaintained since 2005.)
- widget package in Tklib [L1 ] (Limited documentation)
Code in this Wiki
Several wiki pages include code for scrollable widgets and scrolled frames.
Discussion and Refinements
Tk widgets are limited to 32k pixels in height and width. The text and canvas widgets are written to allow much larger contents than the widget size (the viewport for the contents). In contrast, the contents of a scrollable frame are limited to 32k x 32k.
List of all pages in this category (may be stale, select the "References" item from the "Page" menu for the current list):
Fetching backrefs...