Hi David,

On 01/03/2010 2:37 PM, Swingle David-QWHM86 wrote:
Hi, I'd like to scroll a window, but can't seem to get it work.  I've
seen and tried code that scrolls widgets such as a listbox, but I want
to scroll the entire window.  What I would prefer is that there be no
scroll bars unless the user shrinks the window size so that widgets are
now out of view.  First, I tried to associate the scrollbars with a
frame, but I would get errors.  So, I tried using a canvas instead.  The
code I have is below.  It will display scrollbars that do nothing.

In order to scroll a set of widgets (rather than a single widget designed for scrolling), you need to use a megawidget that actually places the items on a canvas (which has a viewport for handling this). Fortunately this case is common enough that there are a couple in the tkkit.

The first is the BWidget ScrolledWindow. You can find an example of that in the tkx-ed code that ships with ActivePerl (look for 'new_ScrolledWindow').

The second (and my preferred) is package 'widget::scrolledwindow', with an example in ActivePerl's lib/ActivePerl/PPM/GUI.pm (look for 'new_widget__scrolledwindow').

Indeed, the PPM GUI sources are a good source of Tkx code. We wrote the UI entirely in Tkx, just leveraging code in tkkit. It has examples for cross-platform considerations, improved styling with use of native themed widgets, and advanced widget use cases.

Regards,

Jeff

Reply via email to