tags:

views:

238

answers:

2

I am creating a simple tool to add album cover images to mp3 files in python. So far I am just working on sending a request to amazon with artist and album title, and get the resulting list, as well as finding the actual images for each result. What I want to do is to display a simple frame with a button/link for each image, and a skip/cancel button.

I have done some googling, but I can't find examples that I can use as a base.

  1. I want to display the images directly from the web. Ie. using urllib to open and read the bytes into memory, rather than go via a file on disk
  2. I want to display the images as buttons preferably

All examples seems to focus on working on files on disk, rather with just a buffer. The TK documentation in the python standard library doesn't seem to cover the basic Button widget. This seems like an easy task, I have just not had any luck in finding the proper documentation yet.

+2  A: 

Hi,

you can modify this using urllib.urlopen(). But I don't know (as I haven't tested it) if you can make this step without saving the (image) file locally. But IMHO urlopen returns a file handle that is usable in tk.PhotoImage().

For jpg files in PhotoImage you need PIL:

from PIL import Image, ImageTk
image = Image.open("test.jpg")
photo = ImageTk.PhotoImage(image)
tuergeist
A: 

For displaying jpgs in Python check out PIL

eb
`PIL` is for manipulating images. It sucks when actually **showing** the results. In fact, `PIL` 's `Image.show()` method saves the image data to a temporary file and invokes an external program to show it.
nosklo