#!/usr/bin/env perl use strict; use warnings; use Tk; my $mw = MainWindow::->new(-title => 'Status Notifications'); $mw->geometry('512x288+50+100'); my $status = 'A'; my $last_status = $status; my $status_msg; _set_status_msg($status, \$status_msg); my $status_bar_F = $mw->Frame( )->pack(-side => 'bottom', -fill => 'x'); $status_bar_F->Label( -textvariable => \$status_msg, -anchor => 'w', -relief => 'sunken', )->pack(-fill => 'x'); my $main_F = $mw->Frame( )->pack(-side => 'top', -fill => 'both', -expand => 1); my $text_F = $main_F->Frame( )->pack(-side => 'right', -fill => 'y'); my $status_text = $text_F->Text( -width => 50, )->pack(); $status_text->insert(end => "$status_msg\n"); my $radio_F = $main_F->Frame( )->pack(-side => 'left', -fill => 'both', -expand => 1); for my $status_letter ('A' .. 'F') { $radio_F->Radiobutton( -text => $status_letter, -variable => \$status, -value => $status_letter, -command => sub { if ($status ne $last_status) { $last_status = $status; _set_status_msg($status_letter, \$status_msg); $status_text->insert(end => "$status_msg\n"); } }, )->pack(-side => 'top', -anchor => 'w', -pady => 2); } MainLoop; sub _set_status_msg { my ($status, $msg_ref) = @_; $$msg_ref = 'Status: ' . $status . '; Changed at: ' . localtime(); return; }