Collecting Text input in a Dialog. - Perl

This is a discussion on Collecting Text input in a Dialog. - Perl ; I new to Perl/Tk programming and am having difficulty. I am confused on how to collect the text entered in the dialog to be seen in the main window. I have the following: use Tk; use Tk: ialogBox; use Tk::BrowseEntry; ...

+ Reply to Thread
Results 1 to 3 of 3

Collecting Text input in a Dialog.

  1. Default Collecting Text input in a Dialog.

    I new to Perl/Tk programming and am having difficulty.
    I am confused on how to collect the text entered in the dialog to be
    seen in the main window.

    I have the following:

    use Tk;
    use Tk:ialogBox;
    use Tk::BrowseEntry;
    my $mw = MainWindow->new(-title=>'Dialog Box');
    my $name;
    my $d = $mw->DialogBox(-title => "Title", -buttons => ["OK",
    "Cancel"]);
    my $be=$d->BrowseEntry(-text=>'Name',
    -variable=>\$name)->pack;
    $mw->Button(-text=>'Show',
    -command=> sub{
    $d->Show})->pack;
    print STDOUT $name;

    MainLoop;


  2. Default Re: Collecting Text input in a Dialog.

    Jac wrote:
    > I new to Perl/Tk programming and am having difficulty.
    > I am confused on how to collect the text entered in the dialog to be
    > seen in the main window.
    >
    > I have the following:
    >
    > use Tk;
    > use Tk:ialogBox;
    > use Tk::BrowseEntry;
    > my $mw = MainWindow->new(-title=>'Dialog Box');
    > my $name;
    > my $d = $mw->DialogBox(-title => "Title", -buttons => ["OK",
    > "Cancel"]);
    > my $be=$d->BrowseEntry(-text=>'Name',
    > -variable=>\$name)->pack;
    > $mw->Button(-text=>'Show',
    > -command=> sub{
    > $d->Show})->pack;
    > print STDOUT $name;
    >
    > MainLoop;
    >

    $name will hold the current value of the BrowseEntry widget.
    Your script prints nothing because you print the value of
    $name while it is still undefined. Put a print statement in
    your button sub after you Show the DialogBox.

    use Tk;
    use Tk:ialogBox;
    use Tk::BrowseEntry;
    my $mw = MainWindow->new( -title => 'Dialog Box' );
    my $name;
    my $d = $mw->DialogBox(
    -title => "Title",
    -buttons => [ "OK", "Cancel" ]
    );
    my $be = $d->BrowseEntry(
    -text => 'Name',
    -variable => \$name
    )->pack;
    $mw->Button(
    -text => 'Show',
    -command => sub {
    $d->Show;
    print "$name\n";
    }
    )->pack;

    MainLoop;

  3. Default Re: Collecting Text input in a Dialog.

    Thank you. I also found the browsecmd and used that to print after a
    selection is made. I was worried about
    getting the data entered back to the main form for use.
    Thanks again.
    Jac


+ Reply to Thread

Similar Threads

  1. retrieving the user input from the onbeforeunload dialog
    By Application Development in forum Javascript
    Replies: 1
    Last Post: 09-19-2007, 09:34 PM
  2. hex input using user dialog box.
    By Application Development in forum labview
    Replies: 4
    Last Post: 08-07-2007, 07:10 PM
  3. ATL::CDataSource and dialog with a connection string in input
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 04-24-2006, 01:32 PM
  4. Help: Input Dialog Box
    By Application Development in forum Java
    Replies: 7
    Last Post: 03-07-2005, 01:19 AM