Donc, j'ai enfin ma classe de base bien installée et prête à construire une classe à tester. Cependant quand j'ai commencé buildign cela, je remarque que je devais me répéter Lot avec la mise tout à l'événement mondialPython Comment utiliser les verables globaux et DRY
le début() est appelée à mettre en place tout mise à jour() est appelée chaque tic-tac (20 tiques une seconde)
Existe-t-il un moyen plus efficace d'utiliser global venerable alors cela.
class BodyClass(BaseClass):
def __init__(self, name):
super().__init__(name)
def Start(self):
global i
i = 0
global d
d = True
global obj1
obj1 = ChildClassA('Obj1')
global obj2
obj2 = ChildClassB('Obj2')
global obj3
obj3 = ChildClassC('Obj3')
global obj4
obj4 = ChildClassB('Obj4')
global obj5
obj5 = ChildClassB('Obj5')
global obj6
obj6 = ChildClassB('Obj6')
def Update(self):
global i
global d
global obj1
global obj2
global obj3
global obj4
global obj5
global obj6
print ("TYPE:", obj3.CType())
i = i+ 1
time.sleep(0.05)
print("i: ", i)
if i >= 10:
if d:
print("UNLOADING")
obj2.Unload()
obj4.Unload()
obj5.Unload()
obj6.Unload()
d=False