from Tkinter import *
import random

def move():
	global ball
	global w
	global x, y, dx, dy
	
	x = x+dx
	y = y+dy
	w.coords(ball, x, y, x+20, y+20)
	w.after(100, move)
		
root = Tk()
w = Canvas(root, width=200, height=200)
w.grid(column=0,row=0)

x=5
y=random.randint(0,200)
dx=2
dy=random.randint(-5,5)
ball = w.create_oval(x, y, x+20, y+20, fill="blue")

w.after(100, move)
	
root.mainloop()