-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathtest.py
More file actions
50 lines (28 loc) · 732 Bytes
/
test.py
File metadata and controls
50 lines (28 loc) · 732 Bytes
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
48
49
50
import numpy as npy
import enthought.traits.api as traits
class C(traits.HasTraits):
x = traits.Float(0.0)
y = traits.Float(1.0)
class MyC(C):
xy = traits.Float(0.0)
def __init__(self, c):
self.x = c.x
self.y = c.y
c.sync_trait('x', self)
c.sync_trait('y', self)
def _x_changed(self, old, new):
self.xy = self.x * self.y
def _y_changed(self, old, new):
self.xy = self.x * self.y
# C objects are created at top level
c = C()
c.x = 1
c.y = 1
class Backend:
def register_c(self, c):
# only gets C objects after creation
self.myc = MyC(c)
backend = Backend()
backend.register_c(c)
c.x = 4
print backend.myc.xy