in reply to Tk input box

Here's another way, perhaps simpler, depending.

I use this to ask for input via a GUI widget, useful when I'm working outside the console on Win32.

use strict; use warnings; use Tk; my $enteredvalue; my $window = MainWindow->new(-title => 'myTitle'); my $entry = $window->Entry(-textvariable => \$enteredvalue)->pack; $entry->bind('<Return>', \&go ); $entry->focus; MainLoop; ### sub go { # Do your thing... }

 

Replies are listed 'Best First'.
Re^2: Tk input box
by JediWizard (Deacon) on Sep 17, 2004 at 13:32 UTC

    If you want to close the main window, in &go, just call $mw->destroy();. I do not however know of any way to stop MainLoop after it has started other than to exit the program all together.

    May the Force be with you
      $mw->destroy() stops MainLoop.