use strict; use warnings; use Tk; use Tk::StatusBar; use Tk::ToolBar; my $mw = MainWindow->new; $mw->geometry('200x80+10+20'); $mw->optionAdd('*Label.font' => '{MS Sans Serif} 8'); my $tb = $mw->ToolBar(qw/-movable 1 -side top/); my $connected = 1; $tb->ToolButton( -image => 'actreload16', -tip => 'back', -command => \&toggle_conn, ); my $sb = $mw->StatusBar(); my $txtstatus = $sb->addLabel( -relief => 'flat' ); my $icostatus = $sb->addLabel( -width => 20, -relief => 'raised', -anchor => 'center', -side => 'right' ); toggle_conn(); MainLoop(); sub toggle_conn { if ($connected) { $connected = 0; my $text = 'Disconnected'; $icostatus->configure( -image => 'connectno16' ); $txtstatus->configure( -foreground => 'darkred', -textvariable => \$text, ); } else { $connected = 1; my $text = 'Connected'; $icostatus->configure( -image => 'connectyes16' ); $txtstatus->configure( -foreground => 'darkgreen', -textvariable => \$text, ); } }