Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

how to use marquee in perl tk?

by virudinesh (Acolyte)
on May 02, 2013 at 11:06 UTC ( [id://1031730]=perlquestion: print w/replies, xml ) Need Help??

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__

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1031730]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found