in reply to Re: How Do I Change A Button Image in Perl TK?
in thread How Do I Change A Button Image in Perl TK?

Yes ! i know this. i've said :" don't examin my syntax !".Even if i use 'Photo' my procedure don't do that i want ! i just want change button's picture during the program run ! thanks man
that many ways to do it (sic !)
  • Comment on Re^2: How Do I Change A Button Image in Perl TK?

Replies are listed 'Best First'.
Re^3: How Do I Change A Button Image in Perl TK?
by eserte (Deacon) on Jun 11, 2004 at 09:00 UTC
    If you want to change the picture, then do
    $button->configure(-image => $photo_object);
    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:
    #!/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;