def create_combobox(self, text, choices, option, default=NoDefault, tip=None, restart=False): """choices: couples (name, key)""" label = QLabel(text) combobox = QComboBox() if tip is not None: combobox.setToolTip(tip) for name, key in choices: combobox.addItem(name, to_qvariant(key)) self.comboboxes[combobox] = (option, default) layout = QHBoxLayout() layout.addWidget(label) layout.addWidget(combobox) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.label = label widget.combobox = combobox widget.setLayout(layout) combobox.restart_required = restart combobox.label_text = text return widget
def create_lineedit(self, text, option, default=NoDefault, tip=None, alignment=Qt.Vertical): label = QLabel(text) label.setWordWrap(True) edit = QLineEdit() layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout() layout.addWidget(label) layout.addWidget(edit) layout.setContentsMargins(0, 0, 0, 0) if tip: edit.setToolTip(tip) self.lineedits[edit] = (option, default) widget = QWidget(self) widget.label = label widget.textbox = edit widget.setLayout(layout) return widget