Not quite as much physics involved here, just a bouncing ball within the Tkinter canvas ...
# an animated red ball bouncing within the Tkinter canvas
# tested with Python27 and Python32
try:
# Python2
import Tkinter as tk
except ImportError:
# Python3
import tkinter as tk
root = tk.Tk()
root.title("Tkinter Bouncing Ball")
w = 420
h = 300
cv = tk.Canvas(root, width=w, height=h, bg='black')
cv.pack()
# 50x50 square box for the circle boundries
x1 = 10
y1 = 50
x2 = 60
y2 = 100
# set x, y increments
dx = 2
dy = 3
# create the ball object
# give it a tag name for reference
ball = cv.create_oval(x1,y1,x2,y2,fill="red", tag='red_ball')
# endless animation loop till window corner x is clicked
while True:
# move the ball by given increments
cv.move('red_ball', dx, dy)
# 15 millisecond delay
# higher value --> slower animation
cv.after(15)
cv.update()
# change direction as ball touches canvas sides
if x2 >= w:
dx = -2
if y2 >= h:
dy = -3
if x1 < 0:
dx = 2
if y1 < 0:
dy = 3
# increment circle box boundries to detect sides touch
x1 += dx
y1 += dy
x2 += dx
y2 += dy
root.mainloop()
Illustrates the use of tag names.