/docs/source/tutorial/008.py

https://bitbucket.org/prologic/circuits/ · Python · 34 lines · 17 code · 13 blank · 4 comment · 0 complexity · 9b1df70bce203541e8575d0061c8ec16 MD5 · raw file

  1. #!/usr/bin/env python
  2. from circuits import Component, Event
  3. class Bark(Event):
  4. """Bark Event"""
  5. class Pound(Component):
  6. def __init__(self):
  7. super(Pound, self).__init__()
  8. self.bob = Bob().register(self)
  9. self.fred = Fred().register(self)
  10. class Dog(Component):
  11. def started(self, *args):
  12. self.fire(Bark())
  13. def bark(self):
  14. print("Woof! I'm %s!" % self.name)
  15. class Bob(Dog):
  16. """Bob"""
  17. channel = "bob"
  18. class Fred(Dog):
  19. """Fred"""
  20. channel = "fred"
  21. Pound().run()