Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

i want to call the sub which is associated with one of the buttons on my tk gui every time the user presses the return key i have been trying to use bind but am getting a sensible result

Replies are listed 'Best First'.
Re: tk bind
by thundergnat (Deacon) on Jun 17, 2005 at 15:20 UTC

    Unless you show some of your code, you are only going to get generic answers.

    use warnings; use strict; use Tk; my $top = MainWindow->new; $top->Button( -text => 'Push Me', -command => \&mysub )->pack; $top->bind('<Return>', \&mysub); MainLoop; sub mysub{ $top->Label( -text => 'You pressed it!' )->pack; }
      my code was basically that posted by thundergnat my problem was that i was getting the function called when the program first ran (i guess coz i had to hit return to run the program) i thought i was going about it completly the wrong way but obviously not coz now it works so thanks a lot
Re: tk bind
by JediWizard (Deacon) on Jun 17, 2005 at 15:46 UTC

    i have been trying to use bind but am getting a sensible result

    You got a result that made sense? Did you want it to not make sense?

    I know you just had a typo, but that was just too funny to pass up. :-)


    They say that time changes things, but you actually have to change them yourself.

    —Andy Warhol

Re: tk bind
by davidrw (Prior) on Jun 17, 2005 at 15:14 UTC
    What code are you trying? What is the (non-) sensible result?