#!/usr/bin/perl use strict; use Tk; use Tk::DialogBox; my $dialog; my $running = 0; my $mw = new MainWindow(-title=>'My Main App'); my $text = $mw->Text(); my $loginbut = $mw->Button(-text=>'Login', -command => \&login)->pack; my $logoffbut = $mw->Button(-text=>'LogOff', -command => sub {$running = 0} )->pack; #&login; MainLoop; ############################################################### sub login{ return if $running; $dialog = $mw->DialogBox( -title => "Login", -buttons => [ "OK", "Cancel" ] ); my $server = 'default'; my $servl = $dialog->add( "Label", -text => 'Server' )->pack(); my $servd = $dialog->add( "Entry", -textvariable => \$server )->pack(); my $name = 'default user'; my $namel = $dialog->add( "Label", -text => ' Name ' )->pack(); my $named = $dialog->add( "Entry", -textvariable => \$name )->pack(); my $passwd; my $passl = $dialog->add( "Label", -text => 'Password' )->pack(); my $passd = $dialog->add( "Entry", -show => "*", -textvariable => \$passwd )->pack(); my $retlog = 0; if ( $dialog->Show() eq "OK" ) { print "$server\t$name\t$passwd\n"; #this line is only for demo #do your stuff here, like reprompt if the #password is bad, or whatever you want # here you would make a callback to a real login sub, # and if it is good, then enable the main gui # $retlog = &real_login($server,$name,$passwd); } #if($retlog == 1){ &start_main } else { &login} }
In reply to Re: perltk-problem related to toplevel widget
by zentara
in thread perltk-problem related to toplevel widget
by perlplayer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |