def __init__(self, cti, delegate, parent=None): """ See the AbstractCtiEditor for more info on the parameters """ super(ColorCtiEditor, self).__init__(cti, delegate, parent=parent) lineEditor = QtWidgets.QLineEdit(parent) regExp = QtCore.QRegExp(r'#?[0-9A-F]{6}', Qt.CaseInsensitive) validator = QtGui.QRegExpValidator(regExp, parent=lineEditor) lineEditor.setValidator(validator) self.lineEditor = self.addSubEditor(lineEditor, isFocusProxy=True) pickButton = QtWidgets.QToolButton() pickButton.setText("...") pickButton.setToolTip("Open color dialog.") pickButton.setFocusPolicy(Qt.NoFocus) pickButton.clicked.connect(self.openColorDialog) self.pickButton = self.addSubEditor(pickButton)
def __init__(self, parent=None): super(ColorSelectWidget, self).__init__(parent=parent) self.mainLayout = QtWidgets.QHBoxLayout() self.mainLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.mainLayout) self.lineEditor = QtWidgets.QLineEdit() self.lineEditor.setToolTip( "Color hex code: a '#' followed by 6 hex-digits.") self.mainLayout.addWidget(self.lineEditor) self.setFocusProxy(self.lineEditor) regExp = QtCore.QRegExp(r'#[0-9A-F]{6}', Qt.CaseInsensitive) validator = QtGui.QRegExpValidator(regExp, parent=self) self.lineEditor.setValidator(validator) self.pickButton = QtWidgets.QPushButton() self.pickButton.setText("Color Picker...") self.pickButton.setToolTip("Open color dialog.") self.pickButton.setFocusPolicy(Qt.NoFocus) self.pickButton.clicked.connect(self.openColorDialog) self.mainLayout.addWidget(self.pickButton)