in reply to DialogBox needs Entry, Text
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.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"; }
|
|---|