Tuesday, 20 August 2013

Add images dynamically based on random number

Add images dynamically based on random number

I work on a simple mathematics learning programs for my 4 year old
daughter with the help of images. Based on a random number that we can
call X, a for loop will run X number of times and print an image X number
of times. The image will be selected from the list by a random number also
that we can call Y.
If X is 2 the image Y will be printed to the screen 2 times using for loop.
The problem is I do not know how to do. :P If anyone can help me with this
I would be grateful! I'm using python 3.2 and Tkinter.
Here is example code for my image list.
self.imageListRegular = []
self.imageListRegular.append(ImageTk.PhotoImage(file="Bilder/Bird-icon.png"))
self.imageListRegular.append(ImageTk.PhotoImage(file="Bilder/elephant-icon.png"))
self.imageListRegular.append(ImageTk.PhotoImage(file="Bilder/fish-icon.png"))
self.imageListRegular.append(ImageTk.PhotoImage(file="Bilder/ladybird-icon.png"))
self.imageListRegular.append(ImageTk.PhotoImage(file="Bilder/zebra-icon.png"))
Sincerely, Robert

No comments:

Post a Comment