From: Masafumi Y. <my...@gm...> - 2014-05-26 03:30:37
|
Hi, 2014-05-26 3:54 GMT+09:00 Michael Below <be...@ju...>: > thanks for your help, this got me a big step further. Now I want to > display a slideshow: I am retrieving images from flickr into an array, > and now I want to iterate through those images with #each > > My code shows only the last image. Seems like the window is not updated > while the initial code is run. I would like to force an update at the > end of each #each iteration. How may I do that? Is there a better way? A GTK window is just shown when `Gtk.main` is called. `show_all` sets flag to be displayed to all widgets, but doesn't actually display until `Gtk.main` is called. It seems that need to design such as the following: * Do paging when an event occurred. ... FlickRaw.api_key= FlickRaw.shared_secret= @pixbufs = [] results = flickr.photos.search(:tags => "tag", :per_page => 1) results.each {|currentresult| ... if myheight > 700 ... end @pixbufs << currentpixbuf } update_image(@pixbufs.first) # event handler signal_connect("key-press-event") do |_widget, event| case event.keyval when Gdk::Keyval::GDK_KEY_Right @pixbufs.push(@pixbufs.shift) update_image(@pixbufs.first) when Gdk::Keyval::GDK_KEY_Left @pixbufs.unshift(@pixbufs.pop) update_image(@pixbufs.first) end end # auto mode GLib::Timeout.add(1000) do @pixbufs.push(@pixbufs.shift) update_image(@pixbufs.first) true # continue end end def update_image(currentpixbuf) if (defined?(@gtkimage)).nil? @gtkimage = Gtk::Image.new :pixbuf => currentpixbuf add @gtkimage else @gtkimage.set_pixbuf(currentpixbuf) end show_all end ... Thanks, -- myokoym |