my $scrollbar = $mw->Scrollbar(-orient => 'vertical); my $raListboxes = [ $mw->Listbox(), $mw->Listbox() ];
Then you create a subroutine that will do the scrolling
sub scrollListboxes { my ($scrollbar, $scrolled, $raListboxes, @args) = @_; $scrollbar->set(@args); my ($top, $bottom) = $scrolled->yview(); foreach my $listbox ( @$raListboxes ) { $listbox->yviewMoveto($top); } }
then configure each listbox to call the routine and configure the scrollbar to scroll each listbox.
foreach my $listbox ( @$raListboxes ) { $listbox->configure( -yscrollcomand => [ \&scrollListboxes, $scrollbar, $listbox, $raListboxes ]); } $scrollbar->configure( -command => sub { foreach my $listbox ( @$raListboxes ) { $listbox->yview(@_); } });
Having set all that up you pack the widgets and away you go. I have not used this code but remembered seeing the example when I saw your post.
I hope this is of use.
Cheers,
JohnGG
Update: Corrected missing comma in 2nd line of code, thanks ikegami
In reply to Re: Double Callbacks?
by johngg
in thread Double Callbacks?
by herby1620
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |