#!perl -w =pod IP & Hostname GUI Program v .3 slojuggler =cut #use strict; use Socket; use Sys::HostIP; #For hostname use Sys::Hostname; print "@INC" . "\n"; my $ipaddr = hostip; print "Mine: $ipaddr \n"; my $hostnm = hostname(); print "Host $hostnm \n"; use Tk; use Tk::DialogBox; my $mw = MainWindow->new; $mw->title("Your IP Info"); $mw->Label(-text=>"IP Address -> $ipaddr") ->pack(-fill => 'x', -side=>"top", -ipadx=>20); $mw->Label(-text=>"Hostname -> $hostnm") ->pack(-fill => 'x', -side=>"top"); $mw->Button(-text=>"Done!", -command=> sub { exit } ) -> pack (-side=>"bottom"); #Somehow pass the $mw to the do_toplevel routine, to keep in step with use strict #$mw->Button(-text=>"About...", -command=> sub { \&do_toplevel ????? } ) -> pack (-side=>"bottom"); $mw->Button(-text=>"About...", -command => sub { do_toplevel($mw) }) -> pack (-side=>"bottom"); MainLoop(); exit(); sub do_toplevel { my $mainwindow = shift; my $dialog = $mainwindow->DialogBox(-title => "About...", -buttons => ["OK"]); my $label = $dialog->add('Label', -text=>"V1.2")->pack(-fill=> 'x', -side=>"top"); $dialog->Show; =pod my $tl = $mainwindow->Toplevel(); $tl->title("About..."); $tl->Button(-text => "Close", - command => sub {$tl->destroy})->pack; $tl->waitWindow(); =cut }