Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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
[Corion]: Ah, cool! So it's not an inhouse youtube but for a wider consumption
[marto]: last time it was IE6 clients, now they're on 11, so more scope there also, in terms of UI and playback
[marto]: in house as in Company network, not internet connected (power stations and the corporate HQs)
[Discipulus]: new Monsignor party! free beverages and pizza for all you monks! and a big thanks for the patience you deserved me during these years
[marto]: congrats Discipulus
[Discipulus]: only 4k points to sundial's level ..;=)
[Corion]: Yay Discipulus ;)
[Corion]: marto: Ah, so this will be training videos etc., cool!
[choroba]: Congratulations!
[marto]: Corion worse, some plant inspection, cameras moving thru pipes

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-07-28 09:21 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (425 votes). Check out past polls.