[pygtk] Updating image without closing window
Timo
timomlists at gmail.com
Wed Aug 5 18:01:16 WST 2009
DINESHBABU DINAKARABABU schreef:
> I found out that widget.queue_draw() should solve the issue. But, I am
> still having doubts on how to use the queue_draw() method.
> It would be great if someone could let me know on how to use the
> method in my 'expose' function and bind it to the "expose_event". My
> expose function is defined as follows:
>
> def expose (da, event, pixbuf):
> ctx = da.window.cairo_create()
> ctx.set_source_pixbuf(pixbuf,0,0)
> ctx.paint()
> ctx.stroke()
Add this line here:
da.queue_draw()
>
> It would be extremely helpful if someone could guide me in this
> regard. I really appreciate the help.
>
> Thanks
>
> On Tue, Aug 4, 2009 at 10:48 AM, DINESHBABU DINAKARABABU
> <dinesh243 at gmail.com <mailto:dinesh243 at gmail.com>> wrote:
>
> Hi all,
>
> I am writing a program to continuously display full screen images
> after getting the raw image data from a remote machine. (Doing it
> using sockets). It would be really helpful if any one of you could
> help me out in solving the issue as I am pretty new to Python and
> PyGTK.
>
> I am able to get the first image image on the screen. But, not the
> remaining images. Is there anyway to display the images
> successively without actually closing the window? In other words,
> is it possible to just update the first image with the update of
> the raw image data?
>
> My image display code is as below. I stop with the image displays
> once I receive a flag = 1 from my remote machine.
> def main():
> flag = 0
> while flag == 0:
> imagedata = conn.recv(1024)
> flag = conn.recv(2)
> pixbuf = gtk.gdk.pixbuf_new_from_data(imagedata,
> gtk.gdk.COLORSPACE_RGB, 0, 8, 480, 320, 1440)
> imgw=pixbuf.get_width()
> imgh=pixbuf.get_height()
> win = gtk.Window()
> pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
> color = gtk.gdk.Color()
> cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
> gtk.Window.fullscreen(win)
> win.connect("realize", lambda obj: win.window.set_cursor(cursor))
> win.connect("key-press-event", key_press_event)
> win.connect('destroy', gtk.main_quit)
> win.set_default_size(imgw, imgh)
> da = gtk.DrawingArea()
> win.add(da)
> da.connect('expose_event', expose, pixbuf)
> win.show_all()
> gtk.main()
>
> I would be grateful if any one can give me any suggestions on how
> to go about solving the problem. I would really appreciate any
> help. Thanks a lot in advance.
>
> --
> Cheers
> DB
>
>
>
>
> --
> Cheers
> DB
> ------------------------------------------------------------------------
>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
More information about the pygtk
mailing list