display monochromatic images wxPython

Mike Driscoll kyosohma at gmail.com
Fri Apr 25 17:28:40 EDT 2008


On Apr 25, 3:42 pm, "wongjoek... at yahoo.com" <wongjoek... at yahoo.com>
wrote:
> Dear All,
> I want to write a GUI program with wxPython displaying an image. But
> the image I have is monochromatic. When I retrieve the data from the
> image I end up with a list of integer. Starting from a list of integer
> and knowing the width and height of the image, how do I display such
> an image on a wx panel or frame ? I have had a look at the wxPython
> demo but there I see only images where the data is a list of tuple
> consisting of r,g ,b values. Is there are function where I directly
> can input the list of array and let it display the image ?
> Thanks in advance
>
> RR

You should be able to create a wx.StaticBitmap object and then set the
photo on it. Something like this:

<code>

# create a blank image holder
img = wx.EmptyImage(240,240)

self.myImageObj = wx.StaticBitmap(self, wx.ID_ANY,
wx.BitmapFromImage(img))
self.myImageObj.SetBitmap(wx.BitmapFromImage(img))

# refresh the widgets
self.Refresh() # where "self" is a wx.Frame

</code>

If that doesn't make sense or doesn't work in your case, please re-
post the question to the wxPython's User group:

http://wxpython.org/maillist.php

Mike



More information about the Python-list mailing list