 |
Linux Format forums Help, discussion, magazine feedback and more
|
| View previous topic :: View next topic |
| Author |
Message |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1360 Location: A hole in a field
|
Posted: Fri Oct 01, 2010 6:15 pm Post subject: Perl |
|
|
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 |
|
 |
bobthebob1234 LXF regular

Joined: Thu Jan 03, 2008 9:38 pm Posts: 1360 Location: A hole in a field
|
Posted: Sun Oct 03, 2010 2:19 pm Post subject: |
|
|
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 |
|
 |
ScannerDarkly
Joined: Sat Jul 17, 2010 10:53 pm Posts: 30 Location: Cardiff
|
Posted: Sun Nov 21, 2010 3:12 am Post subject: |
|
|
Perl's syntax makes my eyes bleed.
Oh sorry, thought this was a Python thread  _________________ Linux since Ubuntu 6.06. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|