f



I can wrap my bindings for debugging -- but it "confuses" 'Tk::Ev's

I'm deriving from Devel::TraceCalls to  to see what's going on inside
my Perl/Tk application. All works well for normal function calls. But
the bindings for keyboard etc. (which would be very helpful to see in
the trace) are often anonymous subs -- which Devel::TraceCalls can not
trace. So I'm wrapping them like this(excerpt!):

my $curbnd = $subw->bind($tag, $sequence);
my $method = $curbnd->[0];
my @params = @{$curbnd}[1..$#$curbnd];

local *$id = sub{ $subw->$method(@params) };
trace_calls{ Subs => [$id] };
$subw->bind($tag, $sequence => \&$id);

where $id is a string containing a name for the wrapper sub.
This works nicely unless the Tk::Callback in $curbnd contains a Tk::Ev

Example: for a Tk::Entry, <Key> is bound to
$VAR1 = bless( [
                 'Insert',
                 bless( do{\(my $o = 'A')}, 'Tk::Ev' )
               ], 'Tk::Callback' );

If my key is the down arrow this should insert nothing, because Ev(A)
evaluates to the empty string for non-unicode keys. In my wrapped
version, however, it inserts a literal 'A'

Any idea how to fix this?

Regards,
Wolfram

0
w
8/23/2007 5:23:08 PM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

1 Replies
487 Views

Similar Articles

[PageSpeed] 56

Ok, found my answer:

from perldoc Tk::callbacks: "Ev(...) inserts callback objects into the
argument list. When perl/Tk glue code is preparing the argument list
for the callback it is about to call it spots these special objects
and recursively applies the callback process to them."

My original wrapper prevented this from happening because the whole
callback is now only one CODE reference and not a reference to an
array of arguments, some of them Tk::Ev objects. This one works
better:

my $curbnd = $subw->bind($tag, $sequence);
local *$id = sub{ my($widget, $method) = (shift, shift); $widget->
$method(@_) };
trace_calls{ Subs => [$id] };
$subw->bind($tag, $sequence => [ \&$id, @$curbnd ]);

Most callbacks have arrays inside, but some have just scalars. To
handle this, replace the last line with:

$subw->bind($tag, $sequence => [\&$id, reftype $curbnd eq 'ARRAY' ? @
$curbnd : $$curbnd]);

Wolfram

0
w
8/24/2007 4:26:06 PM
Reply:

Similar Artilces:

Tk::Browser, "Can't locate object method 'Construct'"
Using perl 5.10, I'm trying to run the Tk::Browser.pm SYNOPSIS example. I get a "Can't locate object method "Construct" via package "Tk::Widget" " error. In more detail --- use strict; use warnings; use Tk::Browser; my $b = new Browser; __END__ gets --- Can't locate object method "Construct" via package "Tk::Widget" at C:/Perl/site/lib/Tk/Frame.pm line 13. Compilation failed in require at (eval 15) line 3. ...propagated at C:/Perl/lib/base.pm line 93. --- etc The "Construct" that can't be located for Tk::W...

how to make ["a","b",["c","d"],"e"] into ['a', 'b', 'c', 'd', 'e'] ?
--001a11c34e8edbc7c404f6a94bbe Content-Type: text/plain; charset=ISO-8859-1 >>> x=["a","b",["c","d"],"e"] >>> y=x[2] >>> y ['c', 'd'] >>> x.insert(2,y[0]) >>> x ['a', 'b', 'c', ['c', 'd'], 'e'] >>> x.insert(3,y[1]) >>> x ['a', 'b', 'c', 'd', ['c', 'd'], 'e'] >>> del x[4] >>> x ['a', 'b', 'c', 'd', &#...

Help! Can't read file with the char's. " / " and "." !
&nbsp; Hi fellows! &nbsp; I got this file : example.&nbsp;&nbsp; &nbsp; 13-06-06 12:30:20,526&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-3,568&nbsp; 13-06-06 12:30:20,529&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-13,528 13-06-06 12:30:20,556&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-30,568 .. .. ..&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; My program writes this file, and in my program i also got a&nbsp; ReadFile.VI, to read this file and plot...

Why """, not '''?
Why is """ the preferred delimiter for multi-line strings? On Mar 5, 9:56 am, MartinRineh...@gmail.com wrote: > Why is """ the preferred delimiter for multi-line strings? Is it ? FWIW, I use single quotes whenever I can and double whenever I have to (i.e. rarely). George On Wed, 5 Mar 2008 06:56:24 -0800 (PST) MartinRinehart@gmail.com wrote: > Why is """ the preferred delimiter for multi-line strings? Where did you see that? The only place I saw it was the style guide and it was only talking about docstrings. Even there they used "...

There's "Unix", and then there's "UNIX(r)"
From TOW[1]: The Open Group, an industry standards consortium, now owns the UNIX trademark and allows its use for certified operating systems compliant with its standard, the Single UNIX Specification. Other operating systems that emulate Unix to some extent may be called Unix-like, although the Open Group disapproves of this term.[4] The term Unix is also often used informally to denote any operating system that closely resembles the trademarked system. The most common version of Unix (bearing certification) is Apple's OS X, while Linux is the most popular non...

Tk's lack of "chrome" (prompted by Re: Tk::FunkyButton ?)
I have had various of list (and even day job) complaints that perk/Tk "looks old fashioned". Also tracking/converting Tcl/Tk is a pain (and core Tk is where most of the "look" comes from). So for perl6 (when it comes) I would rather write/help-out-with a native perl/XS GUI - perhaps by wrapping gtk2. The gtk seems to progressing well on unicode font handling etc. There is at least a "render" library for SVG which would be a start towards a Canvas replacement and/or we could go 3D and use OpenGL (which is usually available somehow these days). ...

Why doesn't Python's "robotparser" like Wikipedia's "robots.txt" file?
For some reason, Python's parser for "robots.txt" files doesn't like Wikipedia's "robots.txt" file: >>> import robotparser >>> url = 'http://wikipedia.org/robots.txt' >>> chk = robotparser.RobotFileParser() >>> chk.set_url(url) >>> chk.read() >>> testurl = 'http://wikipedia.org' >>> chk.can_fetch('Mozilla', testurl) False >>> The Wikipedia robots.txt file passes robots.txt validation, and it doesn't disallow unknown browsers. But the Python pars...

Re: Tk's lack of "chrome" (prompted by Re: Tk::FunkyButton ?)
--- Nick Ing-Simmons <nick@ing-simmons.net> wrote: > > I have had various of list (and even day job) > complaints that perk/Tk > "looks old fashioned". As far as I know, all of this is being addressed in the latest versions of Tk. Now, we should have native support on different platforms, and themes are coming. So the situation will change. > Also tracking/converting Tcl/Tk is a pain (and core > Tk is where > most of the "look" comes from). > > So for perl6 (when it comes) I would rather > write/help-out-with a &g...

'Here's the thing about Apple's "recent"�success.'
'It isn't recent. The only thing that has changed are some numbers. Some big numbers: largest company in the world, second most profitable company in the world, most profitable retail stores in the world, best-selling smart phone, second best-selling smart phone, best-selling tablet computer, etc. Other numbers have not changed: customer satisfaction, customer loyalty, consumer ratings, etc.' <http://granthuhn.wordpress.com/2011/09/23/heres-the-thing-about-apples-r ecent-success/> -- "The iPhone doesn't have a speaker phone" -- "I c...

Tk and xdefaults on windows (prompted by Re: Tk's lack of "chrome")
On Friday 09 December 2005 13:58, Nick Ing-Simmons wrote: > Hans Jeuken <haje@toneel.demon.nl> writes: > >It's not a very serious note what i have to say, > >but in all the shiny glittery new gui's like qt and gtk(2) > >and wrappers like wx, somehow, i don;t find > >perl/Tk looking old fashioned looking, as i have seen > >other people saying in this discussion, > >if you take a little care of your xresources file. > > I well thought out set of xresources can help X11 > for sure. Windows might be a little more tricky > ...

Needed "data processing magazine" also any of same topic are from 50's 60's 70's such as "Datamation", ACM conference proceedings, Early AFIPS, and others.
Needed "data processing magazine" also any of same topic are from 50's 60's 70's such as "Datamation", ACM conference proceedings, Early AFIPS, and others. Also have a requirement for any of the IRE - IEEE publications on early computing. Please advise All eras are fine prefer bound but... loose OK too. address is below. Thanks Ed Sharpe, Archivist for SMECC - - See the Museum's Web Site at www.smecc.org Southwest Museum of Engineering, Communications and Computation Coury House / SMECC Library 5802 W. Palmaire Ave. ...

RE: Tk's lack of "chrome" (prompted by Re: Tk::FunkyButton ?) #18
Vadim Konovalov <vkonovalov@spb.lucent.com> writes: > >What is wrong with non-western language support in perl/Tk or tcl/tk, BTW? 1. Direction support e.g. right to left for Arabic or Hebrew script, and (I think) vertical for Chinese to have a traditional look. 2. Composite characters - while western scripts typically have precomposed accented characters à and digraphs Æ with other scripts these have to be done by kerning accents into right place relative to base character. 3. Context dependant glyphs - Arabic has one code point represented ...

Re: Tk's lack of "chrome" (prompted by Re: Tk::FunkyButton ?) #15
Nick Ing-Simmons wrote: >Paul Falbe <paul@cassens.com> writes: > > >>Now seems a good time to mention some work we've been doing >>with froglogic.com. I needed to do some programming for PDAs running >>Qtopia. Since, I am better programmer in PerlTk then C++/Qt >>I commissioned Harri Porten of froglogic.com to build me >>perlTk emmulator if you will using the Qt toolkit instead >>of Tk. The project is far enough along that I have a 7300+ >>Pq (Perl with Qt) project. The syntax is perlTk but >>uses Qt. >...

Re: Tk and xdefaults on windows (prompted by Re: Tk's lack of "chrome")
This is a multi-part message in MIME format. --------------060901000703020502040104 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, Not sure about where/how the .Xdefaults file is read on Windows, however I am sure that one can read application-specific X resource files on Unix or Windows via the Tk::CmdLine module. (I contributed that code a few years back.) How to do it is in the documentation for Tk::CmdLine. Adios, Hans Jeuken wrote: > On Friday 09 December 2005 13:58, Nick Ing-Simmons wrote: > >> Hans Jeuken...

Web resources about - I can wrap my bindings for debugging -- but it "confuses" 'Tk::Ev's - comp.lang.perl.tk

Resources last updated: 2/2/2016 3:06:25 PM