i am trying to use curses and make a form of TUI but since for me the only curses library that does work is curses-UI and nt forms widgets or any other i am pigeon holed into trying to do it through this only. now i am trying to input a BUTTONbox in the widget for email which would open a question dialog asking for email. after this has been input i want the widget to show a text saying what is the email that has been input. i know its sort of complex way of doing it and but i think this could be user friendly.
my $EMAIL; $w{2}->add(undef, 'Buttonbox', -y => -7, -buttons => [ { -label => " [EMAIL] ", -value => 1, -onpress => sub { my $cui=shift()->root; $EMAIL = $cui->question("PLEASE ENTER +EMAIL:"); if ($EMAIL) { $w{2}->add( undef, 'Label', -y => -10, -text => "The email you entere +d is $EMAIL\n"); } else { $cui->dialog("Question cancelled."); } }, }, ], );
so when ever i run this the Email button does come but after input their is no text at all. so i curse and i am not able to wrap my head around it so... any Advice???

update: here is the runable code of the system:
#!/usr/bin/perl -w use strict; use warnings; use File::Temp qw( :POSIX ); use lib "../lib"; # make KEY_BTAB (shift-tab) working in XTerm # and also at the same time enable colors #$ENV{TERM} = "xterm-vt220" if ($ENV{TERM} eq 'xterm'); my $debug = 0; if (@ARGV and $ARGV[0] eq '-d') { my $fh = tmpfile(); open STDERR, ">&fh"; $debug = 1; } else { # We do not want STDERR to clutter our screen. my $fh = tmpfile(); open STDERR, ">&fh"; } use FindBin; use lib "$FindBin::RealBin/../lib"; use lib "$FindBin::RealBin/perllib"; use Curses::UI; # Create the root object. my $cui = new Curses::UI ( -clear_on_exit => 1, -debug => $debug, -color_support => 1, ); # Demo index my $current_demo = 2; # Demo windows my %w = (); # -------------------------------------------------------------------- +-- # Create the explanation window # -------------------------------------------------------------------- +-- my $w0 = $cui->add( 'w0', 'Window', -border => 1, -y => -1, -height => 3, -bfg => 'red', ); $w0->add('explain', 'Label', -text => "CTRL+B: Back CTRL+O: Options " . "CTRL+X: Menu CTRL+Q: Quit" ); # -------------------------------------------------------------------- +-- # Creating the windows for the front end # -------------------------------------------------------------------- +-- my %screens = ( '2' => 'Options page', ); my @screens = sort {$a<=>$b} keys %screens; my %args = ( -border => 1, -titlereverse => 1, -padtop => 0, -padbottom => 5, -ipad => 5, -bfg => 'red', ); while (my ($nr, $title) = each %screens) { my $id = "window_$nr"; $w{$nr} = $cui->add( $id, 'Window', -title => "Curses::UI demo: $title The APE Test($nr/" . @scree +ns . ")", %args,); $w{$nr}-> add( undef,'Label', -y => 0, -x => 5, -bfg => 'blue', -text => " _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ \n" . "|_ _| | | | | | _ _| | _ | | _ | | +_ _| |_ _| | _ _| | _ _| |_ _| \n" . " | | | |_| | | |_ _ | |_| | | |_| | | | +_ _ | | | |_ _ | |_ _ | | \n" . " | | | _ | | _ _| | _ | | _ _| | +_ _| | | | _ _| |_ _ | | | \n" . " | | | | | | | |_ _ | | | | | | | | +_ _ | | | |_ _ _ _| | | | \n" . " |_| |_| |_| |_ _ _| |_| |_| |_| |_ +_ _| |_| |_ _ _| |_ _ _| |_| \n" ); } ########################## ##### OPTIONS PAGE ##### ########################## my $EMAIL; $w{2}->add( undef, 'Label', -y => -10, -text => "Please add email address here below in the event that th +e results will be mailed to you(Optional)\n" ); my $temp; $w{2}->add(undef, 'Buttonbox', -y => -7, -buttons => [ { -label => " [EMAIL] ", -value => 1, -onpress => sub { my $cui=shift()->root; $EMAIL = $cui->question("PLEASE ENTER EMAIL:"); if ($EMAIL) { $w{2}->add( undef, 'Label', -y => -5, -text => "The email you entered is $EMAIL\ +n"); } else { $cui->dialog("Question cancelled."); } }, }, ], ); # -------------------------------------------------------------------- +-- # Setup bindings and focus # -------------------------------------------------------------------- +-- # Bind <CTRL+Q> to quit. $cui->set_binding( sub{ exit }, "\cQ" ); # Bind <CTRL+X> to menubar. $cui->set_binding( sub{ shift()->root->focus('menu') }, "\cX" ); sub goto_next_demo() { $current_demo++; $current_demo = @screens if $current_demo > @screens; $w{$current_demo}->focus; } $cui->set_binding( \&goto_next_demo, "\cN" ); sub goto_prev_demo() { $current_demo--; $current_demo = 1 if $current_demo < 1; $w{$current_demo}->focus; } $cui->set_binding( \&goto_prev_demo, "\cB" ); sub goto_Options() { $w{2}->focus; } $cui->set_binding( \&goto_Options, "\cO" ); $w{$current_demo}->focus; # -------------------------------------------------------------------- +-- # Get things rolling... # -------------------------------------------------------------------- +-- $cui->mainloop;
as i said before i am using Curses::UI only as i am not able to use the other other libraries probably due to fault of my own as i did include it but when i run them nothing happens even when i tried running the example scripts provided by cpan. i tried using this and it had come into my attention that what i want is that every time i press and enter an email i get a text message below stating what i had typed. after typing it the text message doesnt get display untill i dont press the button once again on top of that if i try changing it the email variable may change in the background but it would always display the same thing what i entered first for example:

if i enter email@address.com at first
after pressing ok it would not show anything until i press d button again

and if enter another address like email247@address.com
it would just show email@address.com.com
so am confused wat to do....pls help...

In reply to Difficulty with Curses by perlassassin27

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.