Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

leriksen's scratchpad

by leriksen (Curate)
on Jun 03, 2004 at 20:05 UTC ( #360452=scratchpad: print w/replies, xml ) Need Help??

I had a problem where I was using an Entry widget, and specifically the -validatecommand option. This takes a callback to a sub that will check that the new data in the Entry widget is OK. Unfortunately, it only calls that callback with data about the change (e.g. the new entry and the original entry), but nothing about which entry widget it came from. And I have dozens of entry widgets in my app, and these changes need to go back to an XML file, and in the right spot in that XML file. A bad solution is to create dozens of callback functions that are all the same, except that they are bound to differnent entry widgets, so I can write to the right part of the XML file.

A better solution was to create a closure that held some info about the piece of XML involved.

sub renderAttribute { my ($self, $xml) = @_; ... # code to create the entry widget for this piece of XML my $entry = $parentFrame->Entry(-textvariable => \$attributeText, -validatecommand => $self->createVal +idateCallback($attributeXML))->pack(); ... } sub createValidateCallback { my ($self, $xmlObj) = @_; return sub { # these params are how Tk will call this callback my ($newValue, $deltaText, $origValue, $deltaIndex, $deltaType) = +@_; return $self->updateXML($xmlObj, $newValue); }; }

Your challenge is that in the closure you have to yield to thread A, and I have no experience in how to do that.

I'll look at that link as soon as I can.

I haven't posted the talk anywhere because it contains a diagram I ripped off verbatim from MJD's new HOP book. I think I'm OK doing a talk with this as a supporting diagram, but a web page is probably just wrong. But I am willing to email it to you, if your willing.


Log In?

What's my password?
Create A New User
[karlgoethebier]: ...because of sausage and luncheon meats...
[karlgoethebier]: ... the ultimate coding experience for everyday people...
[karlgoethebier]: me
[marto]: what a mess
[karlgoethebier]: perhaps i need a zerial?
[Corion]: marto: Heh - I think that's a nice contractual trap, "you will not use other gods/engines besides ours" ;)
[Corion]: But if the base intention was to have CIG as "co-developers" who (have to) contribute changes back to the mainline, it makes sense to have them use no other engine
[marto]: yes, I hear that development house has been on its last legs for a couple of years now
[Corion]: Is anybody aware of what makes Android Oreo better than Android Nougat? I'm not sure if the architectural changes (etc) are there already that make upgrading an Oreo-kernel phone to a newer Android userland (Lineage OS) version feasible

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-12-14 10:31 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (389 votes). Check out past polls.