skywalker has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Can any one point me in the right direction?? I am currently writing a stock control script with Mlistbox as the main module, the in buit sort command is exactly what I want, I can retrive any selected item from the list before sorting, however after the sort, the item returned is the same as before the sort, but the item within the listbox has been sorted. I am sure that there is a simple solution to this problem, but I cant seem to find it or deduce it.
#current selected item in list $grid->bindRows('<Double-Button-1>', sub { my ($w, $infoHR) = @_; print "$customers[$infoHR->{-row}][$infoHR->{-column}]\n", });
Thanks Dan

Replies are listed 'Best First'.
Re: Mlistbox sort
by zentara (Cardinal) on Jan 18, 2008 at 20:33 UTC
    Look at this, and "perldoc Tk::MListbox" for getRow.
    #!/usr/bin/perl use Tk; use Tk::MListbox; use strict; use warnings; my $mw = new MainWindow(); $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 18 ); $mw->fontCreate('medium', -family=>'arial', -weight=>'bold', -size=> 14 ); my $frame = $mw->Frame(-bd => 2, -relief => 'raised')->pack(-expand => + 1, -fill => 'both'); my $scrolledMListbox = $frame->Scrolled( qw/MListbox -selectmode browse -scrollbars oe -font medium / )->pack(-expand => 1, -fill => 'both'); $scrolledMListbox->columnInsert('end', -text => "Sort Me",-font => 'b +ig'); for(1..20){ $scrolledMListbox->insert('end', [int rand 20] ); } $scrolledMListbox->bindRows('<ButtonRelease-1>', sub { my ($w, $infoHR) = @_; print "@_\n"; print "You selected row: " . $infoHR->{-row} . " in column: " . $infoHR->{-column} . "\n"; print $scrolledMListbox->getRow( $scrolledMListbox->curselection() +->[0] ),"\n"; } ); MainLoop;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      Perfect