Hello:

I am trying to use the Python Sleep Function via import time; I get results but not the results I am looking for.

What I am trying to do is rather simple and only for visual effect in a Python GUI: Display GIF --> Sleep (pause) 5-seconds --> Display next GUI --> Repeat. Such as:

[B].[/B]
[B].[/B]
[B].[/B]
 
image3 = "pic1.GIF"
photo3 = PhotoImage(file=image3)
 
time.sleep(5)
 
image4 = "pic2.GIF"
photo4 = PhotoImage(file=image4)
 
[B].[/B]
[B].[/B]
[B].[/B]

What seems to happen is that I do note a pause, in this case roughly 5-seconds, but it happens before the GUI appears at all upon the screen; the canvas should display, then 1-by-1 each GIF should appear 5-seconds apart. Instead the pause occurs approximately 5-seconds after I initiate "RUN" and the entire thing is rendered without pause between GIFs

Any, hints, ideas, or direction would be greatly appreciated.

[** Using Dr.Python]


regards,
sharky_machine

Recommended Answers

All 2 Replies

Hi!

You are using Tkinter, right? Try this: after the time.sleep(), update the GUI with e.g. root.update() (if root is your main window).
I'm not sure if other GUI's need this too.

Regards, mawe

Hi!

You are using Tkinter, right? Try this: after the time.sleep(), update the GUI with e.g. root.update() (if root is your main window).
I'm not sure if other GUI's need this too.

Regards, mawe

Thank-you for your help-- this worked great. ;)

sharky_machine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.