#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; my $c = $mw->Canvas(-width => 400,-height => 210,-bd => 2,-relief => 'sunken',-background => 'black',)->pack; my $image1 = $mw->Photo(-file => './but1.gif', -format => 'gif'); my $image2 = $mw->Photo(-file => './but2.gif', -format => 'gif'); my $but1 = $c->createImage(150, 150, -image => $image1, -anchor => 'ne', -tags => ['but1']); $c->bind( $but1, '', sub { $c->itemconfigure( $but1, -image => $image2); }); $c->bind( $but1, '', sub { $c->itemconfigure( $but1, -image => $image1); }); MainLoop;