| | |
thread,time, sleep
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
hi everyone....... i am writing a program where i have 2 ovals and i want my first oval to appear then after 2 seconds the second one...but am failing in doing this.
can anyone help me to do this please. thank you in advance
here is my code
the problem that i'm having with this is that the computer is waiting for 2 sec then displays both oval but me i want 1 at a time.....
someone please help me in doing this
can anyone help me to do this please. thank you in advance
here is my code
from Tkinter import *
import Tkinter
import time
import thread
frame=Tkinter.Frame()
frame.pack()
canvas =Tkinter.Canvas(frame,bg = 'white',width=500, height=500)
canvas.pack()
def generate():
canvas.create_oval(200,300,210,310) #my first oval
time.sleep(2)
canvas.create_oval(200,300,210,310) # my second oval
button=Tkinter.Button(frame,fg="blue", text="GENERATE", command=generate).pack()
mainloop()the problem that i'm having with this is that the computer is waiting for 2 sec then displays both oval but me i want 1 at a time.....
someone please help me in doing this
Please use the proper code tags around your code. Don't quote the whole thing or your code tags won't work.
Proper code tags are
[code=python]
your code here
[/code]
Please format your code so it is somewhat readable. Also, since your ovals are equal, how would you know the difference?
This how you might do it:
Proper code tags are
[code=python]
your code here
[/code]
Please format your code so it is somewhat readable. Also, since your ovals are equal, how would you know the difference?
This how you might do it:
python Syntax (Toggle Plain Text)
import Tkinter as tk def generate(): oval1() frame.after(2000, oval2) def oval1(): canvas.create_oval(200, 300, 210, 310, fill='red') def oval2(): canvas.create_oval(200, 300, 210, 310, fill='blue') frame = tk.Frame() frame.pack() canvas = tk.Canvas(frame, bg='white', width=500, height=500) canvas.pack() button = tk.Button(frame, fg="blue", text="GENERATE", command=generate) button.pack() frame.mainloop()
Last edited by sneekula; Feb 25th, 2008 at 11:18 am.
No one died when Clinton lied.
![]() |
Similar Threads
- time.sleep() (Python)
- Time to sleep (Python)
- Thread / Timers / Pinging... Help :-s (Python)
- join thread (Java)
- How to capture the system idle time in c/c++ (C++)
- how to kill a thread in python? (Python)
- Interrupt Sleep function (Python)
Other Threads in the Python Forum
- Previous Thread: A little help tweaking the my code
- Next Thread: Python Alarm clock! Absolute novice here!
Views: 1976 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied address ansi backend beginner changecolor class code conversion coordinates copy corners curves customdialog dan08 dictionary directory dynamic edit examples excel feet file float font format ftp function generator getvalue gui halp homework i/o iframe images import info input ip java line linux list lists loop mouse mysql newb number numbers output panel parsing path port prime print program programming projects py2exe pygame pyqt python queue random rational recursion recursive screensaverloopinactive scrolledtext server ssh stamp statictext string strings sudokusolver table terminal text thread threading time tkinter tlapse tuple tutorial type ubuntu unicode url urllib urllib2 variable whileloop windows write wxpython






