perlquestion
gibsonca
<p>
Starting from an example off the web, I want to add these two lines so that they are left justified and vertical to each other. I've missed something. Attached is the complete program - I am just curious on how to fix the "Model File" and the "Range File" widgets. I know there are other issues...
</p>
<c>
#!/usr/bin/perl -w
use Tk;
use strict;
# **********************
# Main()
# **********************
my(
$entry,
$filename,
$output,
);
my $ver = "1.0.0";
my $mw = MainWindow->new;
$mw->geometry("500x600");
$mw->title("GUI 6");
my $main_menu = $mw->Menu();
$mw->configure(-menu => $main_menu);
# give the user a way to exit the script
my $file_menu = $main_menu->cascade(-label=>" ", -underline => 0, -tearoff=>0);
$file_menu->command(-label=>"Exit", -underline=>0, -command => sub{exit});
# everyone needs a little help
my $help_menu = $main_menu->cascade(-label => "Help", -underline => 0, -tearoff => 0);
$help_menu->command(-label => "Version", -underline => 0,
-command => sub{$mw->messageBox(-message => "Version: $ver",
-type => "ok")});
$help_menu->command(-label => "About Program", -underline => 0, -command => \&show_about);
my $pet_info_frame = $mw->Frame()->pack(-side => "top");
$pet_info_frame->Label(-text => "View?")->pack(-side => "top");
my $chk1 = "no";
my $chk2 = "no";
my $pet1_chk = $pet_info_frame->Checkbutton(-text => "Show All",
-variable => \$chk1,
-onvalue => "yes",
-offvalue => "no")->pack(-side => "right");
my $pet2_chk = $pet_info_frame->Checkbutton(-text => "Show Only Differences",
-variable => \$chk1,
-onvalue => "yes",
-offvalue => "no")->pack(-side => "right");
my $model_info = $mw->Frame()->pack(-side => "left");
$model_info->Label(-text => "Model File : ")->pack(-side => "left");
my $model_info_frame = $mw->Frame()->pack(-side => "left");
my $entry1 = $model_info_frame->Entry(
-width => 60,
-textvariable => \$filename
)->grid(
$mw->Button(
-text => "...",
-command => sub {
$filename = $mw->getOpenFile(-title => 'File Browser');
}
),
);
$model_info = $mw->Frame()->pack(-side => "left");
my $range_info = $mw->Frame()->pack(-side => "left");
$range_info->Label(-text => "Range File : ")->pack(-side => "left");
my $range_info_frame = $mw->Frame()->pack(-side => "left");
my $entry2 = $range_info_frame->Entry(
-width => 60,
-textvariable => \$filename
)->grid(
$mw->Button(
-text => "...",
-command => sub {
$filename = $mw->getOpenFile(-title => 'File Browser');
}
),
);
my $button_frame = $mw->Frame()->pack(-side => "bottom");
$button_frame->Button(-text => "Ok", -command => \&update_output)->pack();
#my $output_frame = $mw->Frame()->pack(-side => "bottom");
#my $output_scroll = $output_frame->Scrollbar();
#my $output_text = $output_frame->Text(-yscrollcommand => ['set', $output_scroll]);
#$output_scroll->configure(-command => ['yview', $output_text]);
#$output_scroll->pack(-side => "bottom", -expand => "no", -fill => "y");
#$output_text->pack();
sub update_output {
if ( $chk1 eq "yes" ) { $output = "$output\nShow All"; }
if ( $chk2 eq "yes" ) { $output = "$output\nShow Only Differences"; }
#$output_text->delete('0.0', 'end');
#$output_text->insert("end", $output);
}
sub show_about {
my $help_win = $mw->Toplevel;
$help_win->geometry("300x50");
$help_win->title("About Program");
my $help_msg = "This help page is an example of using multiple windows.";
$help_win->Label(-text => $help_msg)->pack();
$help_win->Button(-text => "Ok", -command => [$help_win => 'destroy'])->pack();
}
MainLoop;
</c>
<p>
Any help appreciated.
Thanks in advance.
</p>