Home > Archive > PerlTk > November 2004 > Process keybord input
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Process keybord input
|
|
| Timo Schneider 2004-11-08, 8:58 pm |
| Hello,
i have a simple Perl/Tk script which just displays an image.
Now i want to call a function if the user hits for example the "Left" Key.
How can i do this?
In which books / online-resources can i look up such things for myself,
so that i don't have to borther you with such "basic" questions anymore?
Thanks a lot,
Timo
| |
| Eric Bohlman 2004-11-09, 3:55 am |
| Timo Schneider <timo.schneider@s2004.tu-chemnitz.de> wrote in
news:cmou4t$uli$1@anderson.hrz.tu-chemnitz.de:
> i have a simple Perl/Tk script which just displays an image.
> Now i want to call a function if the user hits for example the "Left"
> Key.
>
> How can i do this?
That's done by "binding" an event (in this case, a key going down) to one
or more widgets.
> In which books / online-resources can i look up such things for
> myself, so that i don't have to borther you with such "basic"
> questions anymore?
The documentation that comes with Perl/Tk is pretty comprehensive (in your
case, you'll want to start with the docs for Tk::Bind) but it can sometimes
be hard to figure out where to start (it helps if you have the
documentation in a hyperlinked form, as there's *lots* of cross-referencing
in the Tk documentation; I use Sean Burke's wonderful little
Pod::Webserver, which sets up a local webserver that serves up all the Perl
documentation on my system).
For a more tutorial approach, O'Reilly's _Mastering Perl/Tk_ is recommended
by lots of regulars.
| |
| Marc Dashevsky 2004-11-09, 3:55 am |
| In article <cmou4t$uli$1@anderson.hrz.tu-chemnitz.de>, timo.schneider@s2004.tu-
chemnitz.de says...
> Hello,
>
> i have a simple Perl/Tk script which just displays an image.
> Now i want to call a function if the user hits for example the "Left" Key.
>
> How can i do this?
> In which books / online-resources can i look up such things for myself,
> so that i don't have to borther you with such "basic" questions anymore?
The book you must have as you are learning perl/Tk, and even after
you are comfortable working with it, is MASTERING PERL/TK by Steve
Lidie and Nancy Walsh, the former being a contributor to this newsgroup.
In it you will learn of the bind method which associates callbacks
with events, a keystroke being one example of an event.
--
Go to http://MarcDashevsky.com to send me e-mail.
| |
| Richard S Beckett 2004-11-09, 8:55 am |
|
"Timo Schneider" <timo.schneider@s2004.tu-chemnitz.de> wrote in message
news:cmou4t$uli$1@anderson.hrz.tu-chemnitz.de...
> Hello,
>
> i have a simple Perl/Tk script which just displays an image.
> Now i want to call a function if the user hits for example the "Left" Key.
>
> How can i do this?
> In which books / online-resources can i look up such things for myself,
> so that i don't have to borther you with such "basic" questions anymore?
>
> Thanks a lot,
> Timo
$main_window -> bind ('<KeyRelease-A>' => \&subroutine_name);
|
|
|
|
|