Search code examples
pythonarraysnumpygtkglade

How do you display a 2D numpy array in glade-3 ?


I'm making live video GUI using Python and Glade-3, but I'm finding it hard to convert the Numpy array that I have into something that can be displayed in Glade. The images are in black and white with just a single value giving the brightness of each pixel. I would like to be able to draw over the images in the GUI so I don't know whether there is a specific format I should use (bitmap/pixmap etc) ?

Any help would be much appreciated!


Solution

  • In the end i decided to create a buffer for the pixels using:

    self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,0,8,1280,1024)

    I then set the image from the pixel buffer:

    self.liveImage.set_from_pixbuf(self.pixbuf)