drstrangelove
01-18-2001, 11:17 AM
can someone help.
I don't want to be told how to do it, just a few suggestions....
I have started writing a program (that does the same thing as a previous one i wrote that is posted on this board) with Perl/Tk.
I think I am doing it right, because when I click the "no" button I created, it does what it's supposed to.
I created a "yes" button to open a new window, with more choices, but nothing happens when I click it.
Can someone peruse my code and tell me what is wrong and just give some suggestions as to how I could fix it?
Thanks,
Dr. Strangelove
use Tk;
#Windows
$MW = new MainWindow;
$MW->title("MSI");
#Text Labels
$MW->Label("-textvariable"=>\$message,
"-relief"=>'groove',
"-borderwidth"=>2)->pack("-fill"=>'x',
"-side"=>'bottom');
$MW->Label("-text"=>'This program will allow you to add new antennas to your current antenna database. Would you like to continue?',
"-relief"=>'groove',
"-borderwidth"=>2,
"-wraplength"=>100)->pack("-fill"=>'x',
"-side"=>'top');
#Buttons
$B1 = $MW->Button("-text"=>"Yes"
"-command"=>sub {ru_sure;})->pack(-side=>'left',
-fill=>'x',
-expand=>1);
&bind_message($B1, "Press to continue.");
$B2 = $MW->Button("-text"=>"No",
"-command"=>sub
{ exit;
})->pack(-side=>'left',
-fill=>'x',
-expand=>1);
&bind_message($B2, "Press to exit.");
#Subroutines
sub bind_message{
my ($widget, $msg) = @_;
$widget->bind('<Enter>',[sub{
$message = "$_[1]";
},
$msg]);
$widget->bind('<Leave>', sub{
$message = "";
});
}
sub ru_sure{
my $backup_win = $MW->new->title("ALERT!");
$backup_win->Label("-text"=>'Are you sure you have backed up your current antenna database and your new antenna file?',
"-wraplength"=>100,
"-relief"=>'groove',
"-borderwidth"=>2)->pack(-side=>'top',
-fill=>'x');
my $B3 = $backup_win->Button("-text"=>"Yes",
"-command"=>sub {exit;
})->pack(-side=>'left');
&bind_message($B3, "I have backup up, and I am ready to continue.");
my $B4 = $backup_win->Button("-text"=>"No",
"-command"=>sub {exit;
})-pack(-side=>'right');
&bind_message($B4, "I need to backup before we continue.");
}
MainLoop;
[This message has been edited by drstrangelove (edited 18 January 2001).]
I don't want to be told how to do it, just a few suggestions....
I have started writing a program (that does the same thing as a previous one i wrote that is posted on this board) with Perl/Tk.
I think I am doing it right, because when I click the "no" button I created, it does what it's supposed to.
I created a "yes" button to open a new window, with more choices, but nothing happens when I click it.
Can someone peruse my code and tell me what is wrong and just give some suggestions as to how I could fix it?
Thanks,
Dr. Strangelove
use Tk;
#Windows
$MW = new MainWindow;
$MW->title("MSI");
#Text Labels
$MW->Label("-textvariable"=>\$message,
"-relief"=>'groove',
"-borderwidth"=>2)->pack("-fill"=>'x',
"-side"=>'bottom');
$MW->Label("-text"=>'This program will allow you to add new antennas to your current antenna database. Would you like to continue?',
"-relief"=>'groove',
"-borderwidth"=>2,
"-wraplength"=>100)->pack("-fill"=>'x',
"-side"=>'top');
#Buttons
$B1 = $MW->Button("-text"=>"Yes"
"-command"=>sub {ru_sure;})->pack(-side=>'left',
-fill=>'x',
-expand=>1);
&bind_message($B1, "Press to continue.");
$B2 = $MW->Button("-text"=>"No",
"-command"=>sub
{ exit;
})->pack(-side=>'left',
-fill=>'x',
-expand=>1);
&bind_message($B2, "Press to exit.");
#Subroutines
sub bind_message{
my ($widget, $msg) = @_;
$widget->bind('<Enter>',[sub{
$message = "$_[1]";
},
$msg]);
$widget->bind('<Leave>', sub{
$message = "";
});
}
sub ru_sure{
my $backup_win = $MW->new->title("ALERT!");
$backup_win->Label("-text"=>'Are you sure you have backed up your current antenna database and your new antenna file?',
"-wraplength"=>100,
"-relief"=>'groove',
"-borderwidth"=>2)->pack(-side=>'top',
-fill=>'x');
my $B3 = $backup_win->Button("-text"=>"Yes",
"-command"=>sub {exit;
})->pack(-side=>'left');
&bind_message($B3, "I have backup up, and I am ready to continue.");
my $B4 = $backup_win->Button("-text"=>"No",
"-command"=>sub {exit;
})-pack(-side=>'right');
&bind_message($B4, "I need to backup before we continue.");
}
MainLoop;
[This message has been edited by drstrangelove (edited 18 January 2001).]