Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Image in Perl TK?

by hominid (Priest)
on Dec 19, 2008 at 18:58 UTC ( [id://731629]=note: print w/replies, xml ) Need Help??


in reply to Image in Perl TK?

Were you wanting something like this?
#!/usr/local/bin/perl use strict; use warnings; use Tk; use Tk::Photo; my $mw = new MainWindow; $mw -> geometry ("820x780"); my @files = <*gif>; for my $image (@files) { my $shot = $mw->Photo(-file => "$image"); my $btn = $mw->Button(-image => $shot)->pack(); $btn->update; sleep(1); select(undef, undef, undef, .1); $btn->destroy; } $mw->MainLoop;
This gives a slideshow type effect by creating, updating and destroying the button for each image.

Replies are listed 'Best First'.
Re^2: Image in Perl TK?
by zentara (Archbishop) on Dec 19, 2008 at 19:39 UTC
    I havn't tested your script, but destroying widgets in Tk usually leads to memory gains as the program runs. It's better to reuse widgets, rather than using a create/destroy cycle.UPDATE: Just tested it, and your program gains memory. Tk is lousy about cleanup... Gtk2 is much better in that respect.

    I'm not really a human, but I play one on earth Remember How Lucky You Are

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-16 17:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found