Sequencing images using tkinter?

Albert Visser albert.visser at gmail.com
Sat Aug 30 16:49:29 EDT 2014


On Sat, 30 Aug 2014 22:27:01 +0200, <theteacher.info at gmail.com> wrote:

> Although getting next_image to run for e.g. 10 times in a for loop is  
> still something I can't get to work. It only displays one image.

I think this is because you do all your processing befoe starting the  
event loop (myGui.mainloop() ).

A better way is to bind the function that displays the images to a button  
callback.
Referring to your first post, that could be something like (untested)

def rotate():
     for i in range(10):
         myImage = PhotoImage(file="MonsterImages/Converted/" +  
random.choice(monsters))
         myButton1.config(image=myImage, width="100", height="200")
         sleep(0.2)

myButton1=Button(canvas1, text='OK', justify = LEFT, command=rotate)
myButton1.place(x=500,y=300)

myGui.mainloop()

Hope this helps
-- 
Vriendelijke groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/



More information about the Python-list mailing list