-
Notifications
You must be signed in to change notification settings - Fork 259
/
init_order1.py
47 lines (34 loc) · 1022 Bytes
/
init_order1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
This example demonstrates the order of initialization:
* Initial property values are set.
* The init() method gets called.
* Events are handled.
"""
from flexx import app, event
class Example(app.Model):
def init(self):
print('Py: in init')
self.spam = 5
@event.prop
def foo(self, v=2):
print('Py: setting foo')
return v
@event.connect('foo')
def on_foo(self, *events):
for ev in events:
print('Py: handling %s event' % ev.type, self.foo + self.spam)
class JS:
def init(self):
print('JS: in init')
self.eggs = 5
@event.prop
def bar(self, v=2):
print('JS: setting bar')
return v
@event.connect('bar')
def on_bar(self, *events):
for ev in events:
print('JS: handling %s event' % ev.type, self.bar + self.eggs)
if __name__ == '__main__':
m = app.launch(Example)
app.run()