in reply to Re^2: How Do I Change A Button Image in Perl TK?
in thread How Do I Change A Button Image in Perl TK?
where $photo_object is constructed with $mw->Photo or $mw->Pixmap. And do not forget to delete unused photo objects, otherwise you'll got a memory leak. Another alternative is to change the filename in the photo object:$button->configure(-image => $photo_object);
#!/usr/bin/perl use Tk; $mw = tkinit; $p = $mw->Photo(-file => Tk->findINC("Xcamel.gif")); $b = $mw->Button(-image => $p, -command => sub { $p->configure(-file => Tk->findINC("openfolder.xpm")); })->pack; MainLoop;
|
|---|