in reply to Tkx scrolling
G'day nitep70,
Welcome to the Monastery.
I find the autoscroll package handles all types of scrolling cleanly. The basic Tkx code looks like this:
Tkx::package_require('autoscroll'); ... # Automatically mapped scrollbar Tkx::__autoscroll__autoscroll($sb); ... # Fixed scrollbar Tkx::__autoscroll__unautoscroll($sb);
There's a CPAN module, Tkx::Scrolled, which emulates this. You might like to look at its source code to get a few ideas. Be aware, by its own admission: "... we kludge it ..." (see its comments before the '_set' subroutine).
In the code you've posted, some of your g_grid() option values look dodgy. A vertical scrollbar should be "-sticky => 'ns'": you have "-sticky => 'nsew'". Your scrollbar and sizegrip both have "-column => 3, -row => 4": that doesn't look right.
I'm also wondering about text in a canvas widget: a listbox widget seems more appropriate for the scenario you describe.
If you tidy up your code, it will be easier for you to read and less prone to errors. It wasn't a pleasure for me to read: I may have missed things. You can get some hints from perlstyle; also see perltidy — the choice of code layout is yours but, when you have chosen, use it consistently.
There may be other areas that could be improved; however, this code at the start stood out:
my @results=(); my @id6=(); for my $i(0..100) {$results[$i] = 2*$i;} &do_canvas4;
I probably would have written that more like:
my @results = map 2*$_, 0 .. 100; my @id6; do_canvas4();
Using '&subname' is generally not what you want; use 'subname()' unless you really know why you're not. See perlsub for more on that.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tkx scrolling
by nitep70 (Initiate) on Oct 01, 2017 at 21:11 UTC | |
by kcott (Archbishop) on Oct 03, 2017 at 05:02 UTC | |
|