Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How to show selected image with gtk2?

by walto (Pilgrim)
on Jan 08, 2011 at 08:42 UTC ( #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 (Archbishop) on Jan 08, 2011 at 14:53 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
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? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-01-22 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?