Yes, you can make a Tk popup for information, then have it
finish and let the rest of the program run without a gui. When the Tk EventLoop is destroyed, the main program will pickup execution right after the MainLoop line. Usually,
nothing is there, and it exists, but check out this example.
#!/usr/bin/perl
use strict;
use Tk;
use Tk::DialogBox;
my $logincount = 0;
my $mw = new MainWindow();
$mw->withdraw; #hide main window
&login;
MainLoop;
#rest of your script
for(1..100){print "$_\n"; sleep 1}
###############################################################
sub login{
my $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){ $mw->destroy }
else {
$logincount++;
if( $logincount > 3 ) {exit}
&login;
}
}
#########################################################3
sub real_login{
my($server,$name,$passwd) = @_;
my $login_stat = 0;
#do your stuff here... eally tring to connect to server
#assume good
if( $passwd == 1 ){ $login_stat = 1; }
return $login_stat;
}
###########################################################
I'm not really a human, but I play one on earth.
flash japh
| [reply] [d/l] |