How do I implement a dynamic text entry box from a menu choice?
For example, after the user selects Options -> Build, an entry box should appear, sorta like a dialog box for files, so that the user can enter text. The goal is to NOT have the text message box in the GUI. Once the data is entered, the text box would no longer be visible. Could be on a 'return' or an 'exit' button.
I believe the right code would go where the "### ? ###" is in the following -
Typical menu (original source from www.bin-co.com) :
#!/usr/local/bin/perl
use Tk;
# Main Window
my $mw = new MainWindow;
#Making a text area
my $txt = $mw -> Scrolled('Text',-width => 50,-scrollbars=>'e') -> pac
+k ();
#Declare that there is a menu
my $mbar = $mw -> Menu();
$mw -> configure(-menu => $mbar);
# The Main Buttons
my $file = $mbar -> cascade(-label=>"File", -underline=>0, -t
+earoff => 0);
my $others = $mbar -> cascade(-label =>"Others", -underline=>0, -t
+earoff => 0);
my $options = $mbar -> cascade(-label => "Options", -underline=>0, -t
+earoff => 0);
my $help = $mbar -> cascade(-label =>"Help", -underline=>0, -t
+earoff => 0);
## File Menu ##
$file -> command(-label => "New", -underline=>0,
-command=>sub { $txt -> delete('1.0','end');} );
$file -> checkbutton(-label =>"Open", -underline => 0,
-command => [\&menuClicked, "Open"]);
$file -> command(-label =>"Save", -underline => 0,
-command => [\&menuClicked, "Save"]);
$file -> separator();
$file -> command(-label =>"Exit", -underline => 1,
-command => sub { exit } );
## Options Menu ##
$options -> command(-label =>"Build", -underline=> 0,
-command => \&options );
## Others Menu ##
my $insert = $others -> cascade(-label =>"Insert", -underline => 0, -t
+earoff => 0);
$insert -> command(-label =>"Name",
-command => sub { $txt->insert('end',"Name : Binny V A\n");});
$insert -> command(-label =>"Website", -command=>sub {
$txt->insert('end',"Website : http://www.geocities.com/binnyva/\n"
+);});
$insert -> command(-label =>"Email",
-command=> sub {$txt->insert('end',"E-Mail : binnyva\@hotmail.com\
+n");});
$others -> command(-label =>"Insert All", -underline => 7,
-command => sub { $txt->insert('end',"Name : Binny V A
Website : http://www.geocities.com/binnyva/
E-Mail : binnyva\@hotmail.com");
});
## Help ##
$help -> command(-label =>"About", -command => sub {
$txt->delete('1.0','end');
$txt->insert('end',
"About
----------
This script was created to make a menu for a\nPerl/Tk tutorial.
Made by Binny V A
Website : http://www.geocities.com/binnyva/code
E-Mail : binnyva\@hotmail.com"); });
MainLoop;
# -----------
sub options {
# -----------
$gBuild = "TBD";
### ? ###
print "options; build is $gBuild\n";
} # end of options()
sub menuClicked {
my ($opt) = @_;
$mw->messageBox(-message=>"You have clicked $opt.
This function is not implanted yet.");
}
Any help appreciated.