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)
| 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 | |
| 292 | class FeatWidget(object): |