PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 3from circuits import Component, Event
 4
 5class Bark(Event):
 6    """Bark Event"""
 7
 8class Pound(Component):
 9
10    def __init__(self):
11        super(Pound, self).__init__()
12
13        self.bob = Bob().register(self)
14        self.fred = Fred().register(self)
15
16class Dog(Component):
17
18    def started(self, *args):
19        self.fire(Bark())
20
21    def bark(self):
22        print("Woof! I'm %s!" % self.name)
23
24class Bob(Dog):
25    """Bob"""
26
27    channel = "bob"
28
29class Fred(Dog):
30    """Fred"""
31
32    channel = "fred"
33
34Pound().run()