Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tk - Password entry before the main window ? 1

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
HI,

How do i get my Password entry to appear to the user before the main window appears ?

Thanks

Long live king Moshiach !
 
One approach: create and withdraw the MainWindow, so it doesn't appear yet, and have it create a Toplevel for the password.

Code:
use Tk;

my $mw = MainWindow->new;
$mw->withdraw;

my $loginwin = $mw->Toplevel (
   -title => 'Please Sign In',
);
my $password = '';
my $failures = 0; # count failed attempts
$loginWin->Label (
   -text => 'Enter your password to continue:',
);
my $passEntry = $loginwin->Entry (
   -textvariable => \$password,
);
my $submitBttn = $loginwin->Button (
   -text => 'Log In',
   -command => sub {
      if ($password eq 'secret') {
         # show the MainWindow
         $mw->deiconify;
      }
      else {
         # wrong password
         $failures++;
         $password = '';

         if ($failures > 3) {
            exit(0);
         }
      }
   },
)->pack;

MainLoop;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top