in reply to Input from the User
User can press 'Enter' or the OkButton.use strict ; use Tk ; my($mw) = new MainWindow(-title => "Enter Username:") ; my($str) = "usernam_" ; my($endSub) = sub { destroy $mw } ; my($entry) = $mw->Entry(-textvariable => \$str)->pack(-side => 'left', + -fill => 'x', -expand => 1) ; $mw->Button(-text => "Ok", -command => $endSub)->pack(-side => 'left') + ; $mw->Button(-text => "Cancel", -command => sub { exit })->pack(-side = +> 'left') ; $entry->focus ; $entry->icursor('end') ; $entry->bind('<Return>', $endSub) ; MainLoop ; print "result = $str\n" ;
|
|---|