MCPcopy Create free account
hub / github.com/LabPy/lantz / from_feat

Method from_feat

lantz/ui/widgets.py:262–289  ·  view source on GitHub ↗

Return a widget appropriate to represent a lantz feature. :param feat: a lantz feature proxy, the result of inst.feats[feat_name]. :param parent: parent widget.

(cls, feat, parent=None)

Source from the content-addressed store, hash-verified

260
261 @classmethod
262 def from_feat(cls, feat, parent=None):
263 """Return a widget appropriate to represent a lantz feature.
264
265 :param feat: a lantz feature proxy, the result of inst.feats[feat_name].
266 :param parent: parent widget.
267 """
268 _get = cls._WRAPPERS.get
269 #_get = lambda x: x
270
271 if feat.values:
272 if isinstance(feat.values, dict):
273 tmp = set(feat.values.keys())
274 else:
275 tmp = set(feat.values)
276
277 if tmp == {True, False}:
278 widget = _get(QtGui.QCheckBox)
279 else:
280 widget = _get(QtGui.QComboBox)
281 elif not feat.units is None or feat.limits:
282 widget = _get(QtGui.QDoubleSpinBox)
283 else:
284 widget= _get(QtGui.QLineEdit)
285
286 widget = widget(parent)
287 cls.wrap(widget)
288
289 return widget
290
291
292class FeatWidget(object):

Callers 3

__new__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 4

wrapMethod · 0.80
setFunction · 0.50
_getFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected