Again, Downloading and Displaying an Image from the Internet in Tkinter

Dustan DustanGroups at
Tue Jun 6 03:08:50 CEST 2006

I wrote:
> Nobody answered last time. I guess they wanted me to give it a shot.
> Well, here is how I download the image (it's a class method):
>     def download_image(self):
>         save=open("image.jpg","w")
>         save.writelines(web_download.readlines())
>         save.close()
>         web_download.close()
> self.opener is urllib.URLopener(), self.url is the url for the image.
> I display the image as follows:
>         self.image=t.Label(self.frame,image=path+"\\image.jpg")
> t is Tkinter, path is sys.path[0].
> (if sys.path[0] is not the proper way of getting the program's path,
> inform me; I hunted it down without any reference to look to)
> But the image won't display, using any application (including Tkinter,
> paint, Firefox, etc.). I'm assuming the reason it can't be read is
> because the image is protected from downloading.
> So, once again, is there a better way to download and display an image
> using Tkinter?
> Did I try hard enough for you? Are you going to help me this time?

I should probably also mention, the only reason I downloaded the image
to a file was because I don't know of any other way to do it. I feel no
need to save the image to my hard drive.

More information about the Python-list mailing list