kapok
March 9th, 2009, 04:25 AM
i have to get the little green ovals i create to come up on the left side when they leave the right side, visa-versa, same with up and down.
here is the code:
from Tkinter import *
import time
import random
tk = Tk()
################################################## ###############
def update():
enviornment.update()
################################################## ###############
def populate(x):
for y in range(0,x):
y1 = random.randrange(0,400)
x1 = random.randrange(0,400)
y2 = y1 - 10
x2 = x1 - 10
enviornment.create_oval(x1,y1,x2,y2,fill='green')
################################################## ###############
enviornment = Canvas(tk,width=400,height=400)
enviornment.pack()
update()
number_of_cells = 30
populate(number_of_cells)
while True:
for x in range(1,number_of_cells+1):
enviornment.move(x,random.randrange(-2,3),random.randrange(-2,3))
time.sleep(0.01)
update()
here is the code:
from Tkinter import *
import time
import random
tk = Tk()
################################################## ###############
def update():
enviornment.update()
################################################## ###############
def populate(x):
for y in range(0,x):
y1 = random.randrange(0,400)
x1 = random.randrange(0,400)
y2 = y1 - 10
x2 = x1 - 10
enviornment.create_oval(x1,y1,x2,y2,fill='green')
################################################## ###############
enviornment = Canvas(tk,width=400,height=400)
enviornment.pack()
update()
number_of_cells = 30
populate(number_of_cells)
while True:
for x in range(1,number_of_cells+1):
enviornment.move(x,random.randrange(-2,3),random.randrange(-2,3))
time.sleep(0.01)
update()