programming-examples/perl/GUI/Get text input in a single line Text Box.pl
2019-11-15 12:59:38 +01:00

21 lines
359 B
Perl

#!/usr/bin/perl -w
use Tk;
$main = MainWindow->new();
$label = $main->Label(-text=>"Enter user name:");
$label->pack(-side=>"left");
$entry = $main->Entry();
$entry->bind("<Return>", \&handle_return );
$entry->pack(-side=>"left");
MainLoop();
sub handle_return {
$txt = $entry->get();
print "You entered $txt\n";
exit;
}