def create_combobox(self, text, choices, option, default=NoDefault, tip=None): """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() for subwidget in (label, combobox): layout.addWidget(subwidget) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, parent, text, choices = None, option = None, tip = None): super(MyComboBox, self).__init__(parent) """choices: couples (name, key)""" label = QLabel(text) combobox = QComboBox(parent) if tip is not None: combobox.setToolTip(tip) if choices: for name, key in choices: combobox.addItem(name, to_qvariant(key)) layout = QHBoxLayout() for subwidget in (label, combobox): layout.addWidget(subwidget) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.box = combobox
def create_combobox(self, text, choices, option, default=NoDefault, tip=None): """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() for subwidget in (label, combobox): layout.addWidget(subwidget) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) return widget