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 (Cardinal) 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