-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I am trying to write an application using pyGTK and glade-2. For part of the user interface I want to display an image that I generate in my python code. Here is a sample of the test code I have been using so far:
~ image = self.wTree.get_widget('image2') ~ buf=[] ~ for r in range(0, 64): ~ for g in range(0, 64): ~ buf.append('%c' % r) ~ buf.append('%c' % g) ~ buf.append('\x00') ~ imbuf = string.join(buf, '') ~ pixmap = gtk.gdk.pixmap_create_from_data(None, imbuf, 64, 64, 24, fg, bg) ~ image.set_from_pixmap(pixmap, None)
If I am understanding the manual correctly, the problem is that pixmap_create_from_data only creates really only creates a bitmap (i.e. one bit per pixel). The only interface I see that allows multicolor image data without writing the data out to a file and re-reading it with pixmap_create_from_file is gtk.gdk.pixmap_create_from_xpm_d, but it requires putting the data into XPM format. As far as I can tell the XPM format always needs a color map, which is pretty inconvenient because the data I have is going to be raw 24-bit RGB numbers, with potentially lots of different pixel values.
Is there a simple way to display raw 24-bit per pixel image with pyGTK without first writing the data out to a file?
You could try drawing on a DrawingArea with gtk.gdk.Drawable.draw_rgb_image() or maybe a Pixbuf would work for you with gtk.gdk.pixbuf_new_from_inline(). There is a simple example using draw_rgb_data() in the PyGTK 2.0 Tutorial:
http://www.pygtk.org/pygtk2tutorial/sec-DrawingMethods.html
John
_______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
