Well, this is a bit of a drag, I suppose -- and certainly it's something that the DialogBox doc should be more clear about -- but just using "add(Widget)" isn't enough... you have to "->pack()" it, too. Here's a nutshell example of a version that seemed to work for me; it's not pretty, but...
my $addGoalButn = $features->Button(-text=>'Add Goal', -command=> \&mkDialogBox, )->pack(); sub mkDialogBox { $n_prompt = $main->DialogBox(-title=>"Add a \$ value and explanati +on", -buttons=>["OK","Cancel"]); $n_prompt->add(Label, -text=>"\$")->pack(-side => 'left'); $numNewGoal = $n_prompt->add(Entry)->pack(-side => 'left'); $descNewGoal = $n_prompt->add(Text, -height=>'5', -width=>'30')->pack(-side => 'left') +; $n_prompt->Show(); $num = $numNewGoal->get(); $desc = $descNewGoal->get("1.0", "end"); #paid upgrade option: rewrite below for Excel/SQL connectivity $desc =~ s/\s*$/\n/; (open(GF, ">>$file_goals") and print GF join("\n", $num, $desc) and close GF) or warn "unable to save date to $file_goals\n"; }
Note, BTW, a couple subtle changes in the "upgrade" part at the end. (1) it looks like your intent was simply to append to the end of a file, but if it doesn't exist yet, opening "+<$file" will fail. Using ">>$file" will always work (unless there's a disk or permission problem). (2) You don't want to use '\n', unless you really want the literal 2-character string '\n' to show up in the output (i.e. to look exactly like '45\nComment'). (3) It's worth your while to normalize the final whitespace on whatever the user typed into the "description" field; other formatting may be worthwhile as well.

In reply to Re: DialogBox needs Entry, Text by graff
in thread DialogBox needs Entry, Text by monkMAC

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.