my $table = $MainFrame-> MListbox( -selectmode => 'single', -columns=>[ [-text=>'Date', -sortable=>1, + -width => 0], [-text=>'Time', -sortable=>1, + -width => 0], [-text=>'Name', -sortable=>1, + -width => 0], [-text=>'Address', -sortable=>1, + -width => 0], [-text=>'Phone', -sortable=>1, + -width => 0] ] )->pack(-fill=> 'both' +, -expand =>1, -side=>'left', -ipadx => 5);; while($result->fetch()){ ### Results from DB query $table->insert('end', [$Date, $Time, $Name, $Address, $Phone]); } my $scroll = $MainFrame->Scrollbar(-command => ['yview', $table]); table->configure(-yscrollcommand => ['set', $scroll]); $scroll->pack(-side => 'right', -fill => 'y');
When you attempt to scroll you get:error:Not a CODE reference at C:/Perl/site/lib/Tk/MListbox.pm line 72 +3. Tk::Error: Not a CODE reference at C:/Perl/site/lib/Tk/MListbox.pm lin +e 723. Tk::Widget::Callback at C:/Perl/site/lib/Tk/Widget.pm line 1149 Tk::CListbox::yview at C:/Perl/site/lib/Tk/MListbox.pm line 66 Tk::Derived::Delegate at C:/Perl/site/lib/Tk/Derived.pm line 463 Tk::Widget::__ANON__ at C:/Perl/site/lib/Tk/Widget.pm line 322 Tk::MListbox::yscrollCallback at C:/Perl/site/lib/Tk/MListbox.pm line + 700 <Configure> (command bound to event)
If you replace the MListbox with a normal listbox, it works just fine.error:Not a CODE reference at C:/Perl/site/lib/Tk/MListbox.pm line 720 +. error:Not a CODE reference at C:/Perl/site/lib/Tk/MListbox.pm line 72 +0. Tk::Error: Not a CODE reference at C:/Perl/site/lib/Tk/MListbox.pm lin +e 720. Tk::Widget::Callback at C:/Perl/site/lib/Tk/Widget.pm line 1149 Tk::CListbox::yview at C:/Perl/site/lib/Tk/MListbox.pm line 66 Tk::Derived::Delegate at C:/Perl/site/lib/Tk/Derived.pm line 469 Tk::Widget::__ANON__ at C:/Perl/site/lib/Tk/Widget.pm line 322 Tk::MListbox::yview at C:/Perl/site/lib/Tk/MListbox.pm line 911 Tk::Scrollbar::ScrlByUnits at ..\blib\lib\Tk\Scrollbar.pm (autosplit +into ..\blib\lib\auto\Tk\Scrollbar\ScrlByUnits.al) line 336 Tk::Scrollbar::Select at ..\blib\lib\Tk\Scrollbar.pm (autosplit into +..\blib\lib\auto\Tk\Scrollbar\Select.al) line 201 Tk::Scrollbar::ButtonDown at ..\blib\lib\Tk\Scrollbar.pm (autosplit i +nto ..\blib\lib\auto\Tk\Scrollbar\ButtonDown.al) line 159 <Button-1> (command bound to event)
In reply to scrolling MListbox in Perl/tk by vortmax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |