So simply put I want different objects to have their own tick loop code running independently of each other (As in one tick loop does not stop all other tick loops in my app).
I've created a basic module that has a class for shapes and the main body for spawning them however the tick loop of the class holds up the main parts loop.
I have even tried splitting the code into two modules to see if that would work but that still ran the two loops separately.
Here is my code:
(main code)
from random import *
from tkinter import *
from time import *
import RdmCirClass
size = 500
window = Tk()
count = 0
d = 0
shapes = []
canv = Canvas(window, width=size, height=size)
canv.pack()
window.update()
while True:
col = choice(['#EAEA00'])
x0 = randint(0, size)
y0 = randint(0, size)
#d = randint(0, size/5)
d = (d + 0.01)
outline = 'white'
shapes.append(1)
shapes[count] = RdmCirClass.Shape("shape" + str(count), canv, col, x0, y0, d, outline)
shapes[count].spawn()
count = count+1
print("Circle Count: ",count)
window.update()
(Shape Class)
from random import *
from tkinter import *
from time import *
class Shape(object):
def __init__(self,name, canv, col, x, y,d,outline):
self.name = name
self.canv = canv
self.col = col
self.x = x
self.y = y
self.d = d
self.outline = outline
self.age=0
self.born = time()
def death(self):
pass
def tick(self):
self.age = time() - self.born
def spawn(self):
self.canv.create_oval(self.x, self.y, self.x + self.d, self.y + self.d, outline=self.outline, fill = self.col)
while True:
self.tick()