/docs/source/tutorial/009.py

https://bitbucket.org/prologic/circuits/ · Python · 34 lines · 17 code · 13 blank · 4 comment · 0 complexity · c5123e9f5ca34a279d5e415d9c0371bb 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!" % name)
  15. class Bob(Dog):
  16. """Bob"""
  17. channel = "bob"
  18. class Fred(Dog):
  19. """Fred"""
  20. channel = "fred"
  21. Pound().run()