For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > November 2006 > how to bind key









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 how to bind key
Petr Vileta

2006-11-16, 6:59 pm

I can to bind key combination ALT + 1 and can't find solution. What is the
right syntax?
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


Slaven Rezic

2006-11-16, 6:59 pm

"Petr Vileta" <stoupa@practisoft.cz> writes:

> I can to bind key combination ALT + 1 and can't find solution. What is
> the right syntax?


Try:

use Tk;
$top = new MainWindow;
$top->bind("<Alt-Key-1>" => sub { $top->Toplevel->Label(-text => "hello")->pack });
MainLoop;


--
Slaven Rezic - slaven <at> rezic <dot> de

need xpm or ppm output from GD?
http://search.cpan.org/search?mode=...ery=GD::Convert
Petr Vileta

2006-11-16, 6:59 pm

"Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
news:87odr7b40a.fsf@biokovo.herceg.de...
> "Petr Vileta" <stoupa@practisoft.cz> writes:
>
>
> Try:
>
> use Tk;
> $top = new MainWindow;
> $top->bind("<Alt-Key-1>" => sub { $top->Toplevel->Label(-text =>
> "hello")->pack });
> MainLoop;
>

Thank you. I tryed to bind Alt+5 as <Alt-5> and this work. Never dreamt of
this syntax :-)
Please where I can get a list of "key" = <keyname> ? I have Tk from
ActivePerl and I have not full documentation about all existed key names. On
CPAN I foundn't too.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


Slaven Rezic

2006-11-17, 6:58 pm

"Petr Vileta" <stoupa@practisoft.cz> writes:

> "Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
> news:87odr7b40a.fsf@biokovo.herceg.de...
> Thank you. I tryed to bind Alt+5 as <Alt-5> and this work. Never
> dreamt of this syntax :-)
> Please where I can get a list of "key" = <keyname> ? I have Tk from
> ActivePerl and I have not full documentation about all existed key
> names. On CPAN I foundn't too.


Try "Show keyboard symbols" in the widget demonstration program.

Regards,
Slaven

--
Slaven Rezic - slaven <at> rezic <dot> de

Visualize XML files in a Tk text widget:
http://search.cpan.org/search?mode=...y=Tk::XMLViewer
Petr Vileta

2006-11-17, 9:59 pm

"Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
news:87bqn54wfk.fsf@biokovo.herceg.de...
> "Petr Vileta" <stoupa@practisoft.cz> writes:
>
>
> Try "Show keyboard symbols" in the widget demonstration program.
>

I have Tk800.x ;-) I was scan all contents of all files in directory where I
have Perl instaled but without success.
What exact script name you mean? Can you send me this script to my private
mail? petr AT practisoft DOT cz

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)



Slaven Rezic

2006-11-18, 6:57 pm

"Petr Vileta" <stoupa@practisoft.cz> writes:

> "Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
> news:87bqn54wfk.fsf@biokovo.herceg.de...
> I have Tk800.x ;-) I was scan all contents of all files in directory
> where I have Perl instaled but without success.
> What exact script name you mean? Can you send me this script to my
> private mail? petr AT practisoft DOT cz


The "widget" program is normally installed along with Perl/Tk. But
AFAIK the "Show keyboard symbols" demonstration was introduced in
Tk804. But why not install Tk804? Or just build it without installing,
it's always possible to use multiple Tk versions on the same machine.

--
Slaven Rezic - slaven <at> rezic <dot> de

tknotes - A knotes clone, written in Perl/Tk.
http://ptktools.sourceforge.net/#tknotes
Petr Vileta

2006-11-18, 9:58 pm

"Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
news:87slggztzm.fsf@biokovo.herceg.de...
> "Petr Vileta" <stoupa@practisoft.cz> writes:
>
>
> The "widget" program is normally installed along with Perl/Tk. But
> AFAIK the "Show keyboard symbols" demonstration was introduced in
> Tk804. But why not install Tk804? Or just build it without installing,
> it's always possible to use multiple Tk versions on the same machine.
>

Hmm, I assume that Tk804 have still more bugs then Tk800 and I have Perl 5.6
not 5.8 :-) (reason is the same).
How can I have instaled two Tk versions? It seem to be strange. What happen
if I write
use Tk;
in my perl script? Or how to write "use Tk800" or "use Tk804" if I want
select one of these?
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)



Slaven Rezic

2006-11-19, 7:58 am

"Petr Vileta" <stoupa@practisoft.cz> writes:

> "Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
> news:87slggztzm.fsf@biokovo.herceg.de...
> Hmm, I assume that Tk804 have still more bugs then Tk800


Well, it's not that bad. I switched to Tk804 just a few months ago and
all my Perl/Tk programs still run.

> and I have
> Perl 5.6 not 5.8 :-) (reason is the same).


But 5.6 is way worse than 5.8, in my opinion, especially for unicode
support.

> How can I have instaled two Tk versions? It seem to be strange. What
> happen if I write
> use Tk;
> in my perl script? Or how to write "use Tk800" or "use Tk804" if I
> want select one of these?


Are you on Unix or Windows? On Unix, you can build perl
by using "configure.gnu --prefix=/some/other/directory" and so you may
have parallel perl installations. Just use different shebangs for the
different perls.

If you want to have different module versions for the same perl
installation, then just build the module the normal way "perl
Makefile.PL && make all test" but do not install. To use the other
module version you have to say "perl -Mblib=/path/to/module/directory
script" or just put "use blib '/path/to/module/directory'" on top of
the script.

Regards,
Slaven

--
Slaven Rezic - slaven <at> rezic <dot> de

sf-upload: make batch releases on SourceForge
http://sf-upload.sf.net
zentara

2006-11-19, 6:59 pm

On Sun, 19 Nov 2006 03:16:24 +0100, "Petr Vileta" <stoupa@practisoft.cz>
wrote:

>"Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
>news:87slggztzm.fsf@biokovo.herceg.de...
[color=darkred]
> use Tk;
>in my perl script? Or how to write "use Tk800" or "use Tk804" if I want
>select one of these?


There are a couple of ways to do it, and the difference is
how they will be found in the lib path.

Normally, you just install your personal libs to /home/petr/perl5lib

Then when you build Tk, do this:
perl Makefile.PL PREFIX=/home/petr/perl5lib

I believe that ~/petr/perl5lib will be found first, so it might not
be the best if you don't want that Tk to be the default.
So you can alternatively:


mkdir /home/petr/mytk
Makefile.PL PREFIX=/home/petr/mytk

then in your programs, when you want that Tk version:
use lib '/home/petr/mytk';
use Tk;


There may be other ways, but those 2 are the most straightforward.


You can have 2 (or more) perl versions too.
Say you have /usr/bin/perl is version 5.6, and you have Tk800
in there.

You can then install perl 5.8.8 to the default /usr/local/bin/perl.
Then install Tk804.027. The perl in /usr/localbin will be found first,
when doing Tk's "perl makefile.PL", so it will install in
/usr/local/lib/perl5

Then in your scripts, just change versions by either using
#!/usr/bin/perl
or
#!/usr/local/bin/perl
at the top ofyour scripts, and the different Tk version will
be used accordingly.

zentara

--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Petr Vileta

2006-11-20, 3:59 am

"Slaven Rezic" <slaven@rezic.de> píse v diskusním príspevku
news:873b8flk92.fsf@biokovo.herceg.de...
> "Petr Vileta" <stoupa@practisoft.cz> writes:
>
> But 5.6 is way worse than 5.8, in my opinion, especially for unicode
> support.
>

I have another opinion ;-) Perl 5.6 work fine for me if I want to use simple
codepage. Is not important what codepage I use. If I want to use two or more
codepages together then I load module Unicode::Lite and convert from one to
other as I want. It is interresting for example if I get HTML data in
ISO-8859-2 charset and my database is in Windows-1250 :-)
I tryed some my working script to run on Linux and Perl5.8 but some problem
occurs in regexp etc. The reason was be unicode :-)

>
> Are you on Unix or Windows? On Unix, you can build perl

Hmm, I'm on Windoze :-(
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


Petr Vileta

2006-11-20, 3:59 am

"zentara" <zentara@highstream.net> píse v diskusním príspevku
news:ip41m25qbomgf38s0valevfe9dr1p0sfbd@
4ax.com...
> On Sun, 19 Nov 2006 03:16:24 +0100, "Petr Vileta" <stoupa@practisoft.cz>
> wrote:
>
>
>
> There are a couple of ways to do it, and the difference is
> how they will be found in the lib path.
>
> Normally, you just install your personal libs to /home/petr/perl5lib
>

Hoho, apply the brakes :-) I'm on Windoze. But thank you for your
description. I use it later on my future Linux desktop.
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)


Slaven Rezic

2006-11-20, 7:01 pm

"Petr Vileta" <stoupa@practisoft.cz> writes:

> "zentara" <zentara@highstream.net> píse v diskusním príspevku
> news:ip41m25qbomgf38s0valevfe9dr1p0sfbd@
4ax.com...
> Hoho, apply the brakes :-) I'm on Windoze. But thank you for your
> description. I use it later on my future Linux desktop.


Well, yesterday I built Perl/Tk on Windows for Strawberry Perl (a perl
for Windows which comes with a complete build environment). There's no
problem having ActivePerl and Strawberry Perl side by side on the same
machine.

Regards,
Slaven

--
Slaven Rezic - slaven <at> rezic <dot> de

Visualize XML files in a Tk text widget:
http://search.cpan.org/search?mode=...y=Tk::XMLViewer
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com