Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

gtk2-perl: how to update image widget from callback?

by wdef2 (Acolyte)
on Oct 01, 2012 at 11:57 UTC ( #996628=perlquestion: print w/ replies, xml ) Need Help??
wdef2 has asked for the wisdom of the Perl Monks concerning the following question:

Okay I give up. I have googled and googled. I swear there is not a single explicit snippet on the entire web about how to do this in gtk2-perl, which unfortunately says something about the documentation, given that it must be a very common problem. Usually I can find a snippet to show me how to do just about anything in Perl if I look hard enough. Not this time.

I have a widget displaying a default image. Once the action starts in a callback, I want to change that displayed image.

I have tried printing to an indirect filehandle as for communicating between subs, and that doesn't work. I have tried calling $img_scaled->show() or Gtk2 ->main_iteration again in the callback's sub until I'm blue in the face. It just don't work. It seems the main loop is blocked on that callback and simply cannot see a change to that global pixbuf made in a callback. And yet I can pass refreshed text to a textbox in that same UI using the indirect filehandle method.

Help please, O Monks! (*teeth marks on my laptop*).

Comment on gtk2-perl: how to update image widget from callback?
Replies are listed 'Best First'.
Re: gtk2-perl: how to update image widget from callback?
by Anonymous Monk on Oct 01, 2012 at 12:07 UTC
      Oh great more possibly relevant code to wade through. I did google for C examples but not on Perlmonks. That's where I discovered that, in using Gtk2 in C, it seems you can just change the widget and call the the main loop again from the callback - how simple is that! - which does not work in Perl for me. Frankly I'm tired of looking which I why I'm posting, there isn't a single clear blog or doc explaining this in Perl-gtk2. And the gtk2-perl docs are mere type and arg expanders, look auto generated, and show few or no examples whatsoever. Time to move to another toolkit?
        http://www.perlmonks.org/?node_id=975036, which does not show a working solution, suggests this can be done by writing and updating a temp file and using a timeout to periodically clear and reload the image from there. Leaving aside the feeling that a temp file is a kludge, where does this timeout go? In or outside the main loop?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://996628]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2015-07-31 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls