Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Perl

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1368
Location: A hole in a field

PostPosted: Fri Oct 01, 2010 6:15 pm    Post subject: Perl Reply with quote

Why hello there.

I have been set an assignment to make a hangman game with perl and tk.

All is good, however when the user enters a letter and presses the enter key, nothing happens, they need to click on a button to get stuff to happen.

Here is some code
Code:

...
# This is a text-userinput field
my $entryword = $main->Entry(
# width is in characters, not pixel
-width => 20)->place( -x => 440, -y => 175);
...
y $inputButton = $main->Button(-text => 'Take input', -state => "disabled",
-command => sub{sayhello()}
)->place(-x => 440, -y => 355 );
...

I want 'sayhello' to be run when the user has inputted a letter and presses enter.

Even better, the user can only input one letter and 'sayhello' is automatically run when then input one letter...

How would I go about doing this?

Thanks
_________________
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1368
Location: A hole in a field

PostPosted: Sun Oct 03, 2010 2:19 pm    Post subject: Reply with quote

Figured out the enter key bit.

Code:

$main -> bind('<Return>', sub {sayhello()});


so simple.
_________________
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
Back to top
View user's profile Send private message
ScannerDarkly



Joined: Sat Jul 17, 2010 10:53 pm
Posts: 30
Location: Cardiff

PostPosted: Sun Nov 21, 2010 3:12 am    Post subject: Reply with quote

Perl's syntax makes my eyes bleed.

Oh sorry, thought this was a Python thread Very Happy
_________________
Linux since Ubuntu 6.06.
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast