in reply to Re^5: Problem with Tk::Repeat
in thread Problem with Tk::Repeat
Also, instead of the tedious deleting and refilling the listboxes, I use the -listvariable option to show an array. Now, all you need to do is empty and refill the arrays, and the listbox will take care of itself.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my $topframe = $mw->Frame()->pack(-fill=>'x' ); my $mainframe = $mw->Frame()->pack(-expand=>1, -fill=>'both' ); my $exit_b = $topframe->Button(-text=>'Exit', -command=> sub{ exit } )->pack(-side => 'right', -padx=>20 +); my @array1=(); my $l1 = $mainframe->Scrolled('Listbox', -listvariable => \@array1, -scrollbars => 'ose') ->pack( -side => 'left', -expand=>1, -fill=>'both' ); my @array2=(); my $l2 = $mainframe->Scrolled('Listbox', -listvariable => \@array2, -scrollbars => 'ose') ->pack( -side => 'left', -expand=>1, -fill=>'both' ); my @array3=(); my $l3 = $mainframe->Scrolled('Listbox', -listvariable => \@array3, -scrollbars => 'ose') ->pack( -side => 'left', -expand=>1, -fill=>'both' ); &update; my $repeater = $mw->repeat(5000,\&update); MainLoop; sub update { foreach my $arr_ref (\@array1,\@array2,\@array3){ @$arr_ref = (); for (1..100){ push @$arr_ref, rand 10000; #sort @$arr_ref; #do a text sort on filenames $mw->update; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Problem with Tk::Repeat
by padawan_linuxero (Scribe) on May 07, 2008 at 23:55 UTC |