Moving objects in Tkinter

Evjen Halverson evjenh at yahoo.com
Fri Oct 12 15:39:25 EDT 2007


  I have tried to make a Tkinter program make a rectangle move down the window, but did not succeed. All it does is make a rectangle trail.
   What am I doing wrong?
   
 from Tkinter import*
 root = Tk()
 RectangleColor='orange'
 Background=tk_rgb = "#%02x%02x%02x" % (100, 255, 100)
 root.geometry('1000x800+0+0')
 root.title("Moving Object Test")
 w = Canvas (root,width=1000,height=800,bg=Background)
 w.grid()
 import time
 t1=time.time()
 t2=t1
 ti=t2-t1
 x=100
 y=0
 a=0
 rect=Canvas.create_rectangle(w,x,y,200,100,fill=RectangleColor)
  
   
   
 def CLS():
     cls=Canvas.create_rectangle(w,0,0,1000,800,fill=Background)
 while ti<10:
     t2=time.time()
     ti=t2-t1
     y=y+10
     Canvas.create_rectangle(w,x,y,200,100,fill=RectangleColor)
   
     st1=time.time()
     st2=st1
     subti=st2-st1
     root.mainloop()
     time.sleep(100)
   
     while subti<1:
         st2=time.time()
         subti=st2-st1
         a=a+1
     CLS()
   
 #    rect=Canvas.create_rectangle(w,x,y,1000,800,fill=RectangleColor)
   
   
   
 root.mainloop()
   
 quit()
       
---------------------------------
Building a website is a piece of cake. 
Yahoo! Small Business gives you all the tools to get online.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071012/880f2d69/attachment.html>


More information about the Python-list mailing list