Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How to show selected image with gtk2?

by walto (Pilgrim)
on Jan 08, 2011 at 08:42 UTC ( [id://881207]=perlquestion: print w/replies, xml ) Need Help??

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

I designed a gui with glade constisting of a file chooser dialog and an image widget. I want to select an image file and display the image. When I catch the file select signal the image is not set to the new image, but the missing icon symbol is displayed.

Here is the code:
#!/usr/bin/perl # # use strict; use warnings; use Glib; use Gtk2 -init; my $builder = Gtk2::Builder->new(); $builder->add_from_file("image_gtk.glade"); $builder->connect_signals(undef); Gtk2->main; sub filechooserbutton1_file_set_cb { my $filename = shift @_; my $image = $builder->get_object('image1'); $image->set_from_file($filename);# wrong $image->set_from_file($filename->get_filename); #right, this makes + it work }
Sometimes a short break from staring at the code does wonder.

Replies are listed 'Best First'.
Re: How to show selected image with gtk2?
by zentara (Cardinal) on Jan 08, 2011 at 14:53 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2026-01-14 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (118 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.