Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Tk gif animation

by zentara (Archbishop)
on Mar 01, 2013 at 17:52 UTC ( #1021307=note: print w/ replies, xml ) Need Help??


in reply to Tk gif animation

As far as I know, Perl Tk dosn't support transparencies. You will have to put everything on an appropriately colored background to mask the transparency. This works.

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::Animation; my $scr = new MainWindow; $scr->configure(-background=>"black"); $scr->geometry("200x150"); my $canvas = $scr->Canvas(-width,200,-height,100, -background=> "black")->pack(-expand, 1, -fill, 'both'); my $image = $scr->Animation('-format' => 'gif', -data => get_gif() + ); $canvas->createImage( 50,50, -image=> $image); $image->blank; my $buttonframe = $scr->Frame()->pack(-expand=>1, -fill=>'both'); my $start = $buttonframe->Button(-text => 'Start', -command => sub{ $image->start_animation(40); } )->pack(-side=>'left'); my $stop = $buttonframe->Button(-text => 'Stop', -command => sub{ $image ->stop_animation; $image ->blank } )->pack(-side=>'right'); MainLoop; sub get_gif{ #base64encoded gif89a ... Tk accepts images in base64encoded format as + -data my $gif = 'R0lGODlhIAAgAPMAAP////zzBf9kAt0IBvIIhEYApQAA1AKr6h+3FABkEVYsBZBxOsDAw +ICAgEBA QAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/h1HaWZCdWlsZGVyIDAuMSBieSBZdmVzIFBpZ3 +VldAAh +QQECgD/ACwAAAAAIAAgAEMEgxC82SS4OOvNb6sfVT1dyX1AQ6YhuZpwh7agyL5xjoFf5d +U606x3 CwZrvh1vgjNqesOm8xSdSXXWTXbKSj2iV67y9g2JlcPuuat6tizrHzn+i9Iz4F74uPx6z1 +BEW05I bn+EQBhMI1xZfXsxVnZrgZN3bCplcGKCKjOALChynImXbDgRACH5BAQKAP8ALAAAAAAgAC +AAQwSG sLUHqr04a9uAlFw3baQGfuJYrpv4dNdJndPbUewqV99D4bkgL+VzCUk74sujOupoNg/Quc +NUnUwp dIo1KXvd2Cd7pRotvmV4qE0xuWu2pDiPk2vnLmpcFrpgIVJYZWk3ekZKcH5/RHZ7UHZWX4 +ZrfBN9 fkwgcopPgpIeh589nUEykHGnIhEAIfkEBAoA/wAsAAAAACAAIABDBIywtfckeCDrzbu2Uy +ZNGOad aAeSDRCmsNiGM2m64zffMbquvF5v19qAgkLOaInD1Cq75OlljEp1LmgTeVU9odSubIXLis +thSuVy Rmsl3LYMzTLLlzW7eFLEhpNWGWotcTBHLluFMUdAcjh4TY5KXxaKi0CHe499mVKdfpYemS +MUbHtE X3c1jZJ+f44gEQAh+QQECgD/ACwAAAAAIAAgAEMEhhDI1kB7MuvNNbVURWFdaW7iU3np6W +ZhDJIZ GT4Y/e6weKkWHY/zuVhmuKEyNFv1gsrOpfiLvqi4mxXFpEK3RR0OKFymsFsXVuVMH2Xcr1 +szrpSX GN94ftbPQTF+fyxIH3dDXVMtYIBOYVaPcUZRkTc5aWFrfD5og08jbG2YekB/Mh+DZxkRAD +s='; return $gif; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh


Comment on Re: Tk gif animation
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1021307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2015-07-04 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls