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

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 ;-)


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

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://486837]
Approved by GrandFather
[Corion]: Hi Discipulus!

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-10-18 07:43 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (243 votes). Check out past polls.