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.


In reply to tk how to create entry box from menu selection by gibsonca

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.