Advertisement
Guest User

Untitled

a guest
May 2nd, 2011
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #!/usr/bin/env python2.6
  2.  
  3.  
  4. def main():
  5.     from Tkinter import Tk, Canvas, BOTH
  6.    
  7.     root = Tk()
  8.     canvas = Canvas(master=root, background='white')
  9.     canvas.pack(fill=BOTH, expand=1)
  10.     root.geometry("300x200")
  11.     root.resizable(0, 0)
  12.    
  13.     oval = canvas.create_oval(30, 80, 40, 90, outline='black', fill='red')
  14.        
  15.     x = 1
  16.     y = 1
  17.     xpos = 35
  18.     ypos = 85
  19.        
  20.     while True:
  21.         canvas.move(oval, x, y)
  22.  
  23.         xpos += x
  24.         ypos += y
  25.         if not (295 > xpos > 5):
  26.             x *= -1
  27.         if not (195 > ypos > 5):
  28.             y *= -1
  29.  
  30.         root.after(10)
  31.         root.update()
  32.  
  33.    
  34.  
  35. if __name__ == '__main__':
  36.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement