944,161 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 240399
  • Python RSS
Nov 30th, 2006
0

Python Sleep Function:

Expand Post »
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:

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


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
Similar Threads
Featured Poster
Reputation Points: 105
Solved Threads: 1
Posting Maven
mattyd is offline Offline
2,582 posts
since Oct 2006
Nov 30th, 2006
0

Re: Python Sleep Function:

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
Reputation Points: 19
Solved Threads: 58
Junior Poster
mawe is offline Offline
133 posts
since Sep 2005
Nov 30th, 2006
0

Re: Python Sleep Function:

Click to Expand / Collapse  Quote originally posted by 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
Featured Poster
Reputation Points: 105
Solved Threads: 1
Posting Maven
mattyd is offline Offline
2,582 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Python Error-- cannot find file
Next Thread in Python Forum Timeline: Something similar to def in Tkinter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC