Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading an image from filename in a wx.Panel

I'm seeking a sample code to load a PNG image inside a wx.Panel, I've seen a couple of them using Python Imaging Library (PIL) and a hug bunch of code line.

I would like to keep my environment with as few library as possible, which means without PIL since I don't need to do any kind of image processing and I suppose that wx enable such processing.

Thanks

EDIT : code to achieve this from Mike's answer

image = wx.Image('path/to/image.png', wx.BITMAP_TYPE_ANY)
imageBitmap = wx.StaticBitmap(myPanel, wx.ID_ANY, wx.BitmapFromImage(image))

Then imageBitmap can be used as any other wx widget.

like image 836
AsTeR Avatar asked Jan 12 '12 21:01

AsTeR


1 Answers

I wrote a really simple image viewer tutorial here that might help you: http://www.blog.pythonlibrary.org/2010/03/26/creating-a-simple-photo-viewer-with-wxpython/ It just uses wxPython, I think.

like image 106
Mike Driscoll Avatar answered Nov 04 '22 05:11

Mike Driscoll