Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageTimo 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.
Post Follow-up to this messageIn 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.
Post Follow-up to this message
"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);
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.