Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Tk Error

by kiruthika.bkite (Scribe)
on Mar 27, 2010 at 04:17 UTC ( #831315=note: print w/ replies, xml ) Need Help??

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.

Comment on Re: Tk Error
Download Code
Replies are listed 'Best First'.
Re^2: Tk Error
by GrandFather (Sage) 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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://831315]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2015-10-09 01:42 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (232 votes), past polls