1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 __docformat__ = 'reStructuredText'
20
21 from pytilities import mangle
22 from . import Vector
25 - def __init__(self, target, x_attribute, y_attribute):
26 self.__target = target
27 self.__x_name = mangle(target, x_attribute)
28 self.__y_name = mangle(target, y_attribute)
29
30 @property
32 return getattr(self.__target, self.__x_name)
33
34 @x.setter
36 return setattr(self.__target, self.__x_name, value)
37
38 @property
40 return getattr(self.__target, self.__y_name)
41
42 @y.setter
44 return setattr(self.__target, self.__y_name, value)
45
48
49 """
50 `Vector` whose x and y values are stored elsewhere.
51
52 Put differently, it creates a vector view of an x and a y value.
53
54 For `Vector` specific documentation, see `Vector`.
55 """
56
57 - def __init__(self, target, x_attribute, y_attribute):
58 """
59 Construct a `BoundVector`
60
61 X and y attributes will be looked up on `target` with names
62 `x_attribute` and `y_attribute`.
63
64 Parameters:
65
66 target
67 the object to bind to. The object on which the x and y
68 attributes reside.
69
70 x_attribute :: string
71 name of attribute of the x value on the target
72
73 y_attribute :: string
74 name of attribute of the y value on the target
75 """
76 assert(isinstance(x_attribute, basestring))
77 assert(isinstance(y_attribute, basestring))
78
79 Vector.__init__(self, _DelegatedStorage(target,
80 x_attribute,
81 y_attribute))
82