I have the following program:
#! C;\perl\bin\perl -w
use Tk;
$mw = MainWindow->new;
# Create necessary widgets
$f = $mw->Frame->pack;
$mw->Menubutton(-text => "Menubutton",
-menuitems => [[ 'command' => "IPconfig", -command => \&ipconfig],
[ 'command' => "Item 2"],
"-",
[ 'command' => "Item 3"],
[ 'command' => "Item 4"]])->pack;
$f->Button(-text => "Ipconfig", -command => \&ipconfig)->
pack;
$f->Button(-text => "netstat", -command => \&netstat)->
pack;
$f->Button (-text => "Exit", -command => sub {exit})->pack;
$t = $mw->Scrolled("Text"
->pack;
MainLoop;
# load_file checks to see what the filename is and loads it if possible
sub ipconfig {
my @array1 = `ipconfig /all`;
foreach (@array1) {
print $t->insert("end", $_);
}
}
sub netstat {
my @array1 = `netstat -rn`;
foreach (@array1) {
print $t->insert("end", $_);
}
}
I want to add a button to clear the text window after a command is run.
Anyone know the subroutine to do that?
Thanks
#! C;\perl\bin\perl -w
use Tk;
$mw = MainWindow->new;
# Create necessary widgets
$f = $mw->Frame->pack;
$mw->Menubutton(-text => "Menubutton",
-menuitems => [[ 'command' => "IPconfig", -command => \&ipconfig],
[ 'command' => "Item 2"],
"-",
[ 'command' => "Item 3"],
[ 'command' => "Item 4"]])->pack;
$f->Button(-text => "Ipconfig", -command => \&ipconfig)->
pack;
$f->Button(-text => "netstat", -command => \&netstat)->
pack;
$f->Button (-text => "Exit", -command => sub {exit})->pack;
$t = $mw->Scrolled("Text"
MainLoop;
# load_file checks to see what the filename is and loads it if possible
sub ipconfig {
my @array1 = `ipconfig /all`;
foreach (@array1) {
print $t->insert("end", $_);
}
}
sub netstat {
my @array1 = `netstat -rn`;
foreach (@array1) {
print $t->insert("end", $_);
}
}
I want to add a button to clear the text window after a command is run.
Anyone know the subroutine to do that?
Thanks