Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Gtk2-perl: Create thumbnail pages

by insaniac (Friar)
on Aug 26, 2005 at 10:42 UTC ( #486837=perlquestion: print w/ replies, xml ) Need Help??
insaniac has asked for the wisdom of the Perl Monks concerning the following question:

Hi monkies ;-)

I'm building a tool which will allow me to modify/set EXIF information for images (and prolly more in the future). This is my very first Gtk2 application. I've found the gtk-perl tutorial and I also know where to look up the API.

The subject is somewhat misleading: I *do* know how to create thumbnails et al., my problem is: my application freezes when I'm generating the thumbs, and of course, when all thumbs are generated, *pling* the application is back. How can I avoid this, and maybe use a Gtk2::ProgressBar to indicate that thumbs are being generated.
Or even better: how can update/redraw my application to show thumbs when they're being generated? So that you seem them appearing one at a time.

Ideas, hints, ... everything will be appreciated ;-)

Thanks!!

ugly try-out code for displaying the thumbs
for my $image (@images) { last if $total_count++ == 55; if(not $count){ $thumb_line = Gtk2::HBox->new(FALSE,1); $thumb_page->pack_start($thumb_line,FALSE,FALSE,5); } print "Thumbing ". $image->name."\n"; my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($image->name); my ($width,$height) = ($pixbuf->get_width, $pixbuf->get_height +); my ($scale_width,$scale_height) = $width > $height ? (80,70) : + (70,80); my $new_pixbuf = $pixbuf->scale_simple($scale_width,$scale_hei +ght,'GDK_INTERP_BILINEAR'); my $event_box = Gtk2::EventBox->new; $thumb_line->add($event_box); $event_box->show; my $image_widget = Gtk2::Image->new(); $image_widget->set_from_pixbuf($new_pixbuf); $image_widget->set_size_request(80,80); $image_widget->show; $event_box->add($image_widget); $event_box->signal_connect('button_press_event',\&image_clicke +d_event, $image->name); $event_box->window->set_cursor(Gtk2::Gdk::Cursor->new('hand1') +); $thumb_line->show; #$pbar->pulse(); #$pbar->show; $count = 0 unless ++$count < 10; $window->show; }

to ask a question is a moment of shame
to remain ignorant is a lifelong shame

Comment on Gtk2-perl: Create thumbnail pages
Download Code
Re: Gtk2-perl: Create thumbnail pages
by phenom (Chaplain) on Aug 26, 2005 at 11:11 UTC
    Try changing your code to:
    for my $image (@images) { Gtk2->main_iteration while Gtk2->events_pending;
    I had the same problem too. (see phenom's scratchpad).
      Ah thanks a lot! I can see my progressbar progressing :-D

      and i think that with this line, i can also construct the code to show the thumbs one at a time... great great, thanks again dude!

      to ask a question is a moment of shame
      to remain ignorant is a lifelong shame

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2015-07-04 13:56 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 (60 votes), past polls