Bagarre has asked for the wisdom of the Perl Monks concerning the following question:

Hello fellow Perl people

I've been playing around with tie::Win32MemMap for the last day or so and can't figure out why it wont work with Tk's "-variable" or "-textvariable" fields.

I have a working program that updates a status bar:

$Status{'Total'} = 5; $s_bar->Label(-textvariable => \$Status{'Total'} )->pack();

That works great! Any time 'Total' changes, the status bar changes as well. But, when I try to tie that hash, all my values go away in the gui (But are still there in the hash when I look at it in the debugger)

tie %Status, 'Tie:Win32MemMap', { Create => Mem_New_Share, MapName => +'F_Status', Size => 10000 }; $Status{'Total'} = 5; $s_bar->Label(-textvariable => \$Status{'Total'} )->pack();

Now, the status bar shows nothing at all. Not even the initial value of 5. If I access 'F_Status' from another program, I see the value of 5 and can also change it... and confirm it's changed in another program...ie tie::Win32MemMap seems to be working perfectly.

Is there an issue with using tie and using Tk like this? I was hoping to use this as a way for other processes to report back to a central gui without making children and pipes.

Thanks for any insight to this.

Happy Turkey Day!!

Entities should not be multiplied unnecessarily.

Replies are listed 'Best First'.
Re: Tie::Win32MemMap and Tk
by PodMaster (Abbot) on Nov 26, 2003 at 15:13 UTC
    This cannot work (at least not without modification). Tk has its own event loop (MainLoop), and Tie::Win32MemMap(or Win32::MemMap) has its own (or it has a polling mechanism .... the docs have details). If you want this to work, you have to get them to cooperate.

    update: see Give me my gui back! (specifically Re: Why not replace MainLoop?) for help on that (cooperation).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.