Hello and good afternoon.
I'm new to python an Tkinter. My task : a triggered camera writes 12 images every
70 seconds in a specific folder. The newest 12 images should be visible in a frame at
12 labels ( labels are able to display images ? ). I made two small programms.
One shows 12 images ( even the newest , as disered ), but then thats all , no update
when newer images comes in. The second loops infinite ( I made print statements which
prints numbers, to see the sequence of the actions ) , but show never any image at a
label. Is there someone with time and knowledge to help me ? !!
Here my code :
import Tkinter as tk from PIL import Image, ImageTk import os ROW = 3 COLUMN = 4 TITLE = "TK 5 FormenScan" IMAGE_PATH = "C:/Python26/AVT/" RESIZE_IMAGE_WIDTH = 200 RESIZE_IMAGE_HEIGHT = 130 class Image_Viewer(tk.Frame): def __init__(self, root): tk.Frame.__init__(self, root) print '1' self.bilder() def bilder(self): self.images = self.load_images() print '2' for row, images in enumerate(self.images): print'5' for column, image in enumerate(images): print'6' tk.Label(self, image = image).grid(row = column, column = row) self.after(2000,self.bilder()) def load_images(self): images = sorted(os.listdir(IMAGE_PATH),reverse=True) print'3' sorted_images = list() print'4' for i in xrange(ROW): print'7' l = list() for i in xrange(COLUMN): print'8' l.append(ImageTk.PhotoImage(Image.open("%s%s" %(IMAGE_PATH, images.pop())).resize((RESIZE_IMAGE_WIDTH, RESIZE_IMAGE_HEIGHT)))) sorted_images.append(l) return sorted_images if __name__ == '__main__': root = tk.Tk() root.title(TITLE) image_viewer = Image_Viewer(root) image_viewer.pack() root.mainloop()
please , excuse my poor englisch , it's not my natural language. To make it worse ,
I'm a doing image processing for industrial purposes and not a programmer.