def _create(self, name, value): value_type = type(value) if name in valid_options: widget = QComboBox() elif value_type is bool: widget = QCheckBox(name) elif value_type is int: widget = QSpinBox() elif value_type is float: widget = QDoubleSpinBox() elif value_type is str: widget = QLineEdit(value) elif value_type is list or value_type is tuple: widget = QGridLayout() for icol, val in enumerate(value): spinbox = QSpinBox() if value_type is int else QDoubleSpinBox() spinbox.setMinimum(int(-1e10)) spinbox.setMaximum(int(1e10)) spinbox.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) widget.addWidget(spinbox, 1, icol, 1, 2) else: raise ValueError('unknown type {}'.format(value_type)) return widget
def _create(self, name, value): value_type = type(value) if name in valid_options: widget = QComboBox() elif value_type is bool: widget = QCheckBox(name) elif value_type is int: widget = QSpinBox() elif value_type is float: widget = QDoubleSpinBox() elif value_type is str: widget = QLineEdit(value) # widget.setAcceptDrops(True) # widget.dragEnterEvent = (lambda x: x.accept() # if x.mimeData().hasUrls # else x.ignore()) LineEditSimpleDragDrop(widget) elif value_type is list or value_type is tuple: widget = QGridLayout() for icol, val in enumerate(value): spinbox = QSpinBox() if value_type is int else QDoubleSpinBox() spinbox.setMinimum(int(-1e10)) spinbox.setMaximum(int(1e10)) spinbox.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) widget.addWidget(spinbox, 1, icol, 1, 2) else: raise ValueError('unknown type {}'.format(value_type)) return widget