Re: Want to force update of GtkImage widget
- From: Andrew <rugby471 gmail com>
- To: gtk-list gnome org
- Subject: Re: Want to force update of GtkImage widget
- Date: Fri, 10 Jun 2011 07:15:48 +0100
On 10/06/11 02:34, paul papper wrote:
> Hi all, my first post here. Bear with me, I'm also new to Gtk...
>
> Rather than posting alot of code I'll try to describe my problem on a
> more conceptual level and would like to hear if what I'm trying to do
> and how I go about it seems sound.
>
> I have an industrial camera from which I can manage to grab and save to
> disk as many pictures as I like. I do this in a loop which resides in a
> callback function which is called when the take pictures button is
> clicked. Number of pictures to take is specified by the user in a
> GtkTextEntry. So far so good. What I also want is that a GtkImage-widget
> should be updated to immediately display each new picture. This doesn't
> happen. Only the last picture taken will be displayed and this happens
> exactly when the "take pictures"-button callback returns. I guess the
> gtk-main loop has my request for widget update
> [gtk_image_set_from_pixbuf(snapshot, pixbuf)] queued and will do my
> request after it's done with the callback. I've tried some functions
> like gtk_widget_show_now and gtk_widget_queue_draw right after the call
> to gtk_image_set_from_pixbuf(snapshot, pixbuf), to no avail, obviously.
>
> Any suggestions would be so welcome!
Hi Paul,
What I would do, is instead of using a GtkImage, use a GtkDrawingArea.
For this you would have to write an expose-event callback, in which you
would use gdk_cairo_set_source_pixbuf() to set the source for the Cairo
Drawing Operation and then use cairo_context_paint() to paint it
Then in your callback function of retrieving the image, I would set the
pixbuf you create as a private member of a class, or a global variable
and then just retrieve that in the expose-event callback (remember also
to call gtk_widget_queue_draw() in the callback for the retrieval of the
image)
Hope this helps :)
--
Andrew
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]