in reply to Tk Error

Did you create MainWindow object.
I have executed your code like the following.
use strict; use warnings; use Tk; my $mainWindow=MainWindow->new; my $textEntry = $mainWindow->Entry(-state => 'normal') -> pack( -side +=> 'bottom', -expand => 'BOOLEAN'); $textEntry -> bind('<Return>' => &get); sub get { my $text = $textEntry -> get(); print "$text\n"; } MainLoop;
It worked correctly for me.

Replies are listed 'Best First'.
Re^2: Tk Error
by GrandFather (Saint) on Mar 27, 2010 at 05:05 UTC

    What did you try? I ran your code and got exactly the error OP reported - when I pressed the return key in the text edit field.

    After altering the code as suggested in my reply (posted over an hour before your reply) the code works as the OP requires. You could try it (the modified code) yourself as a check. You need to type something into the text edit control then press return and observe that whatever you typed is printed to the console.


    True laziness is hard work
      I was just missing the \ in front of the sub routine call &get. Thanks guys just a dumb typo on my part.