jpeg files displayed in a loop

Fernando Pérez fperez528 at yahoo.com
Mon Dec 10 09:24:33 EST 2001


Kevin Cazabon wrote:
> # ok, probably a couple minor typos, but it should be that simple.
> 

Well, you got me curious. Here is the code with some things corrected. This 
actually runs, but it hangs at the first image. My cpu usage pegged at 100% 
and I just had to kill the job, it wasn't going anywhere. Any ideas?


#!/usr/bin/env python

import Tkinter
import Image, ImageTk
import os

dir = "/usr/local/home/fperez/local/python/jpegs"


def showimage():
    image = files.pop()
    files.append(image)
    image = ImageTk.PhotoImage(Image.open(image)) #ok, do try/except
    b.configure(image=image)
    b.update_idletasks()
    b.after(1000, showimage)

a = Tkinter.Tk()
b = Tkinter.Label(a)
b.pack()

files = os.listdir(dir) # ok, check them for file types...
os.chdir(dir)
while 1:
    showimage()




More information about the Python-list mailing list