from Tkinter import *
import random

def move():
	global ball
	global gameCanvas
	global x, y, dx, dy
	
	x = x+dx
	y = y+dy
	if y<0:
		y = 0
		dy = -dy
	elif y>180:
		y = 180
		dy = -dy
	gameCanvas.coords(ball, x, y, x+20, y+20)
	gameCanvas.after(100, move)
		
root = Tk()
gameCanvas = Canvas(root, width=200, height=200)
gameCanvas.grid(column=0,row=0)

x=10
y=random.randint(10,190)
dx=2
dy=random.randint(-5,5)
ball = gameCanvas.create_oval(x, y, x+20, y+20, fill="blue")

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