Adding text to a Gtk2::Label from another thread.



Hi all,

This is my first program using perl-Gtk2. Indeed it's my first program
using Gtk2 at all. And my first program using Perl's threading. So please
bear with me.

I have a function drawGui that (surprise, surprise) draws the GUI for
my program. I call this like:

        $guiThread = threads->create(\&drawGui);

and then the script goes on to do other non-GUI stuff in a giant
while loop. It is a jukebox application, so this while loop basically
consists of checking a queue of songs, popping the first and playing
it, or if there are no songs in the queue playing a random song.

The GUI is responsible for pushing things onto the queue and seems to do
this fairly OK.

However, the GUI also has a Gtk2::Label control for displaying details
about the current song (title, artist, album, etc) and I need a way of
updating this control from the aforementioned while loop.

I have tried using a threads::shared style:

        my $statusfield : shared = Gtk2::Label->new;
        
But that doesn't seem to work at all.

Any ideas anyone?

For reference, full source so far can be found here:

        http://www.goddamn.co.uk/tobyink/Software/linux/jukebox/jukebox.pl.html
        
Thanks in advance.

-- 
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

Attachment: pgp59L_SxE09V.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]