Maybe something like this?
class AltImageWin(wx.Frame):
"""
Scrolled window for viewing image
"""
def __init__(self,parent,content):
wx.Frame.__init__(self,parent,-1,title='ImageViewer')
stream = StringIO.StringIO(content)
try:
img = wx.ImageFromStream(stream)
h=img.GetHeight()
w=img.GetWidth()
except Exception,e:
wx.MessageBox("Error: %s" % str(e))
self.Destroy()
return
#wx.MessageBox("height: %d width: %d" % (h,w))
self.scroll = wx.ScrolledWindow(self,-1)
self.scroll.SetScrollbars(1,1,w,h)
wx.StaticBitmap(self.scroll,-1,wx.BitmapFromImage(img))
Jerry
···
On Jul 19, 2007, at 3:10 PM, Nicholas Hansford wrote:
Sorry, not use to this thing. I guess I should explain what I'm attempting. I need to be able to display an image inside of a window in wxpython. Easy enough I thought. Well after a long search on the internet, I found that this can be accomplished using a combination of python image library and wx. What follows is the source code:
def pilToBitmap(self, pil):
return self.imageToBitmap(self.pilToImage(pil))def pilToImage(self, pil):
image.SetData(pil.convert('RGB').tostring())
return imagedef imageToPil(self, image):
pil = Image.new('RGB', (image.GetWidth(), image.GetHeight()))
pil.fromstring(image.GetData())
return pilObviously, I call piltoBitmap with the image I have. However, when the program encounters the wxEmptyImage(...) it says the module doesn't exist. I was wondering if it was something I'd done wrong, or if it had been removed/renamed. Sorry for the confusions.
On 7/19/07, Stephen Hansen < apt.shansen@gmail.com> wrote:On 7/19/07, Nicholas Hansford <nick.hansford@gmail.com> wrote: Ok, I think this is going on the listserv now. Anyway, is the module wxEmptyImage still in wxpython? I really need it. If it is no longer known by that name, could you please tell me what the new one is?