Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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
Re^2: Tk Error
by GrandFather (Cardinal) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-12-26 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls