def __init__(self, label='Label', parent=None, text='text'): super(LabeledLineEdit, self).__init__(parent=parent) layout = QHBoxLayout() self.setLayout(layout) layout.addWidget(QLabel(label)) layout.margin = 0 layout.setContentsMargins(0, 0, 0, 0) self.lineEdit = QLineEdit() self.lineEdit.setText(text) layout.addWidget(self.lineEdit)
def __init__(self, label='Label', parent=None, items=[], itemLabels=None): super(LabeledComboBox, self).__init__(parent=parent) layout = QHBoxLayout() self.setLayout(layout) layout.addWidget(QLabel(label)) layout.margin = 0 layout.setContentsMargins(0, 0, 0, 0) self.comboBox = QComboBox() layout.addWidget(self.comboBox) self.hasLabels = False if not itemLabels: self.comboBox.addItems(items) else: for item in zip(itemLabels, items): self.comboBox.addItem(item[0], item[1]) self.hasLabels = True