Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

how to use marquee in perl tk?

by virudinesh (Acolyte)
on May 02, 2013 at 11:06 UTC ( #1031730=perlquestion: print w/replies, xml ) Need Help??
virudinesh has asked for the wisdom of the Perl Monks concerning the following question:

1. am need marquee in my main window
2. need simple example for this one..

Replies are listed 'Best First'.
Re: how to use marquee in perl tk?
by marto (Bishop) on May 02, 2013 at 11:13 UTC
Re: how to use marquee in perl tk?
by hdb (Prior) 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
Node Status?
node history
Node Type: perlquestion [id://1031730]
Approved by marto
help
Chatterbox?
[Corion]: Maybe doing a double-fork (daemonizing) can make go that information away, but maybe not
[Corion]: But I think my knowledge of unix/Linux datastructures is several decades out of date, so I don't really know what information it keeps on processes
[oiskuu]: The useful bits that relate to your process can be found under /proc/self. What information are you thinking of? Tty name?
[tye]: I just daemonized and getlogin() still knew who I had been.
[tye]: perhaps loginuid ? Not that I concede that something not being in /proc means it is not useful.
[Corion]: tye: That's really interesting, but maybe it is because getlogin() returns the name, or the uid, so if that user has been replaced by another user with the same uid in the meantime, that's no problem to the system...
[davido]: or on ubuntu /var/run/utmp
[Corion]: Otherwise, I would imagine that a user with a process still alive would lock that information in memory.
[davido]: so last -f /var/run/utmp on ubuntu provides similar (though more verbose) info

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-06-23 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (554 votes). Check out past polls.