20
25
33
34 PROP_NAME = 0
35 PROP_DESC = 1
36 PROP_FNAM = 2
37 PROP_TYPE = 3
38
39 ELPROP_NAME = 0
40 ELPROP_DESC = 1
41 ELPROP_FNAM = 2
42 ELPROP_TYPE = 3
43 ELPROP_DFLT = 4
46 res = []
47 for p in props:
48 r = ()
49 for idx in cols:
50 r.append(p[idx])
51 res.append(r)
52 return res
53
56
58
59 _props = []
60 _elem_props = []
61
63 """ use this to apply properties as a dictionary, e.g.::
64
65 x = klass(..., StyleName='class-name')
66
67 will do::
68
69 x = klass(...)
70 x.setStyleName('class-name')
71
72 and::
73
74 x = klass(..., Size=("100%", "20px"), Visible=False)
75
76 will do::
77
78 x = klass(...)
79 x.setSize("100%", "20px")
80 x.setVisible(False)
81 """
82
83 self.applyValues(**kwargs)
84
86
87 for (prop, args) in kwargs.items():
88 fn = getattr(self, "set%s" % prop, None)
89 if not fn:
90 raise Exception("setter function for %s does not exist in %s" % (prop, self.__class__.__name__))
91 args = kwargs[prop]
92 if isinstance(args, tuple):
93 fn(*args)
94 else:
95 fn(args)
96
98 """ use this function to obtain a dictionary of properties, as
99 stored in getXXX functions.
100 """
101
102 res = {}
103 for prop in args:
104 fn = getattr(self, "get%s" % prop, None)
105 if not fn:
106 raise Exception("getter function for %s does not exist" % prop)
107 res[prop] = fn()
108
109 return res
110
111 @classmethod
114
115 @classmethod
118
123
125 args = {}
126 for p in self._getProps():
127 val = app_context.getAppProperty(p[0])
128 convert_to_type = p[PROP_TYPE]
129 if convert_to_type:
130 val = convert_to_type(val) if val else None
131 args[p[PROP_FNAM]] = val
132
133 self.applyValues(**args)
134
136 args = {}
137 for p in self._getElementProps():
138 if elemProps.has_key(p):
139 val = elemProps[p]
140 convert_to_type = p[ELPROP_TYPE]
141 if convert_to_type:
142 val = convert_to_type(val) if val else None
143 else:
144 val = p[ELPROP_DFLT]
145 if val is None:
146 continue
147 args[p[ELPROP_FNAM]] = (context, val,)
148
149 self.applyValues(**args)
150