Dear Monks,

I am creating a simple logon window with two Labels for the user name and password and two buttons for Login and Exit.

What I have been trying to do is to get the Login button to be pressed upon the user hitting the enter key after the password is typed in rather than them having to use the mouse to actually press the button.

The script itself works so far apart from this minor piece of formatting

Forgive this rather mundane question but I can't find the answer in the documentation.

Many thanks
my $main = MainWindow->new; $main->configure(-title => 'Verify User', -background=>'blue'); $main->geometry('+300+300'); my $top = $main->Frame(-background=>'blue', -relief=>'sunken')->pack(-side=>'top',-fill=>'x'); my $left1 = $top->Frame(-background=>'blue', )->pack(-side=>'left',pady=>9,padx=>8); my $left2 = $top->Frame(-background=>'blue', )->pack(-side=>'left',pady=>9,padx=>8); my $user_frm = $left1->Frame(-relief => 'groove', -borderwidth=>3, -background=>'blue', )->pack(-side=>'top',-fill=>'x'); my $user_lbl = $user_frm->Label(-text=> 'Enter Username', -background=>'blue',-foreground=>'white', )->pack(-side=>'left'); my $user_en = $user_frm->Entry(-width=>8, -background=>'white',)->pack(-side=>'left',-pad +y=>3); my $pass_frm = $left1->Frame(-relief => 'groove', -borderwidth=>3, -background=>'blue', )->pack(-side=>'top',-fill=>'x'); my $pass_lbl = $pass_frm->Label(-text=> 'Enter Password', -background=>'blue',-foreground=>'white', )->pack(-side=>'left'); my $pass_en = $pass_frm->Entry(-width=>12, -show=>'*', -background=>'white',)->pack(-side=>'left',-pad +y=>3); my $button = $left2 ->Button(-text => 'Exit', -underline => 0, -width => 10, -borderwidth=>3, -command => sub{do_exit()} )->pack; my $button1 = $left2 ->Button(-text => 'Connect ', -width => 10, -borderwidth=>3, -command => sub{do_submit("$user_en, $pass_en")} )->pack; MainLoop;

In reply to TK button on pressing enter by howarda

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.