Reputation:
I am wondering, is it possible to display images in python?
Upvotes: 3
Views: 12999
Reputation: 11
Using wx.Python here is an example. The picture printed is 'bitmaps/image.jpg'. It prints on the panel using the wx.StaticBitmap() class. from Main import opj
def showPic(frame, nb, log):
jpg = wx.Image(opj('bitmaps/image.jpg'), wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
panel = wx.Panel(nb, -1)
wx.StaticBitmap(panel, -1, jpg, (10, 10))
return panel
Upvotes: 0
Reputation: 3080
The easiest way is to use a web server I reckon. You can script a nice, simple server with bottle and turn out a UI with images.
It depends what you want to do. Python can do it all, but needs something to work with. There's pygame and stuff like that if you're just starting out.
Upvotes: 0
Reputation: 5599
The question needs more clearing up. Do you want to put the picture on a system display? Or on a window in a desktop app? Or render it to a http response?
Python can do all these things in different manners, but for people to explain it - you need to specify your question a bit more.
Upvotes: 1
Reputation: 318698
The various OpenCV bindings for Python also provide ways to display images (and videos). Might be a bit heavy if you just want to display an image.
Upvotes: 0
Reputation: 76965
Almost all GUI toolkits (wxWindows, pyQt, pyGTK, Tkinter) have Canvas or other-type widgets that allow you to draw an image.
The standard library way to draw an image is to use Tkinter's Canvas
widget.
Upvotes: 5
Reputation: 308520
The easiest way is to use PIL and the Image.show method. This brings up an external viewer program on the image.
Upvotes: 9