Usually you use a Dialog for this, a toplevel is used only when the Dialog gives you problems. Try this:
#!/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} }

I'm not really a human, but I play one on earth Remember How Lucky You Are

In reply to Re: perltk-problem related to toplevel widget by zentara
in thread perltk-problem related to toplevel widget by perlplayer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.