I've been using this as a template:
and pretty much the only difference I can find is he uses the line:
from Tkinter import *
whereas I use the line
import Tkinter as Tk
I thought I accounted for this by making all my calls to Tkinter modules as Tk.(Blob.py equivalent). I can this blob animation example to run, but my program gets the error:
'Nonetype' object not callable
on the line:
allStars[i] = allStars[i]()
from my code below (this particular line is in the last block of code):
class Star:
def __init__(self, canvas, xy, delta):
self.canvas = canvas
self.delta = delta
self.id = self.canvas.create_rectangle(
xy[0],xy[1],
xy[0]+starSize,xy[1]+starSize,
fill='white'
)
def __call__(self):
return self.down
def down(self):
xy = self.canvas.coords(self.id)
if xy[1] >= gameScreenHeight:
x2 = random.randint(1,gameScreenWidth)
y2 = 0;
self.canvas.coords(self.id,x2,y2)
else:
self.canvas.move(self.id, 0, self.delta)
root = Tk.Tk()
root.title("Stars")
root.resizable(0,0)
TkPlacement = "%dx%d%+d%+d" % (gameScreenWidth, gameScreenHeight, 10*starSize, heightOffset)
root.geometry(TkPlacement)
frame = Tk.Frame(root, bd = 5, relief=Tk.SUNKEN)
frame.pack()
space = Tk.Canvas(frame, width = gameScreenWidth, height = gameScreenHeight, cursor = 'plus')
space.pack()
space.create_rectangle(0,0,gameScreenWidth,gameScreenHeight,fill="black")
allStars = [
Star(space, (10,30),3),
Star(space, (15,60),3),
Star(space, (80,50),5)
]
#N = 99;
#for i in range(N):
# x1 = random.randint(1,gameScreenWidth)
# y1 = random.randint(1,gameScreenHeight)
# aStar = Star(space, (x1,y1), 3)
# allStars.append(aStar)
root.update()
try:
while 1:
for i in range(len(allStars)):
allStars[i] = allStars[i]()
root.update_idletasks() # redraw
root.update() # process events
except Tk.TclError:
pass # to avoid errors when the window is closed