#!/usr/bin/perl -w
use strict;
use vars qw($VERSION $aboutWindow $mainWindow $camelanim);
use Tk;
$VERSION = "0.01";
# Make the main window, menu bar and Help menu.
$mainWindow = new MainWindow (-title => "A program",);
my $mb = $mainWindow->Frame(-relief => 'raised', -borderwidth => 2);
$mb->pack(
-fill => 'x',
-expand => 'false',
);
my $helpB = $mb->Menubutton(
-text => 'Help',
-underline => 0,
);
$helpB->menu(-tearoff => 0);
$helpB->pack(-side => 'right');
$helpB->command(
-label => 'About...',
-underline => 0,
-command => \&aboutViewer,
);
MainLoop;
# Show module information.
sub aboutViewer {
require Tk::Animation;
require Tk::ROText;
if ($aboutWindow) {
$aboutWindow->deiconify;
$aboutWindow->focus;
$camelanim->start_animation(200);
}
$aboutWindow = $mainWindow->Toplevel(-title => 'About Viewer');
my $top = $aboutWindow->Frame->pack(-fill => 'x', -expand => 'true
+',);
my $right = $top->Frame->pack(-side => 'right');
my $left = $top->Frame->pack(-side => 'left');
$left->Message(
-text => "Copyright (C) 2001 by Your Name Here",
-relief => 'flat',
-width => 400,
)->pack(-fill => 'x', -expand => 'true',);
$camelanim = $right->Animation(
'-format' => 'gif',
-file => Tk->findINC('anim.gif')
) unless $camelanim;
$right->Label(-image => $camelanim)->pack;
$camelanim->start_animation(200);
my $aboutText = $aboutWindow->Scrolled(
'ROText',
-scrollbars => 'oe',
-wrap => 'word',
-width => 40,
-height => 20,
)->pack(
-fill => 'x',
-expand => 'true',
);
$aboutText->insert('end',"$0 $::VERSION\n") if defined($::VERSION)
+;
foreach (&moduleDump) {
$aboutText->insert('end',$_);
}
$aboutWindow->Button(Name => 'okayButton',
-text => 'Okay',
-command => sub { $aboutWindow->withdraw; },
)->pack(-side => 'bottom');
$aboutWindow->bind(
'<Destroy>',
sub {
undef($aboutWindow);
$camelanim->stop_animation;
}
);
$aboutWindow->bind(
'<Unmap>',
sub {
$camelanim->stop_animation;
}
);
}
# Roll credits.
sub moduleDump {
my ($module, $line, @out, %package_stab, $package_version);
foreach (sort(keys %INC)) {
next unless /^[A-Z]/;
$module = $_;
$module =~ s/\.pm$//;
$module =~ s/\//::/g;
%package_stab = eval("%{*" . $module . "::}");
if (exists $package_stab{'VERSION'}) {
$package_version = $package_stab{'VERSION'};
$package_version = $$package_version;
if (defined($package_version)) {
$line = $module . " version $package_version\n";
}
else {
$line = $module . ", no version\n";
}
}
else {
$line = $module . ", no version\n";
}
push @out, $line;
}
return @out;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.