http://www.perlmonks.org?node_id=1031730

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: how to use marquee in perl tk?
by marto (Cardinal) on May 02, 2013 at 11:13 UTC
Re: how to use marquee in perl tk?
by hdb (Monsignor) on May 02, 2013 at 13:08 UTC
    use strict; use warnings; use Tk; my $text = "this is a test..."; my $mw = new MainWindow; $mw->Label(-textvariable=>\$text)->pack(-fill=>'both'); $mw->repeat(200,[sub{$text=~s/(.)(.*)/$2$1/}]); MainLoop;

    Based on marto's advice above.

Re: how to use marquee in perl tk?
by Anonymous Monk on May 02, 2013 at 12:43 UTC
    #!/usr/bin/perl -- use strict; use warnings; use Tk; Main( @ARGV ); exit( 0 ); sub Main { my $mw = tkinit; my $marq = marq( $mw , [ 'Anonymous Monk loves the color pink and +pancakes', ] ); $mw->Button( -text => 'stop', -command => sub { $marq->{_marq_timer}->cancel; } )->pack( qw/ -anchor nw / ); $marq->configure(qw/ -background pink /); $marq->pack(qw/-anchor nw /); marq( $mw , [ @INC ] )->pack(qw/-anchor sw -expand both /); $mw->MainLoop; } sub marq { my( $mw, $messages ) = @_; my $width = 20; $messages = ' ' x $width . join(' --- ', @$messages ); my $position = 0; my $showthis = ""; my $label = $mw->Label( -width => $width, -textvariable => \$showt +his); $label->{_marq_timer} = $mw->repeat( 50, sub { if( $position > length $messages ){ $position = 0; } my $format = '%-'.$width.'s'; my $newmsg = sprintf $format, substr $messages, $position, + $width; $position++; $showthis = $newmsg; return; }, ); return $label; }; __END__