def __init__(self, parent = None, minimum = camelot_minint, maximum = camelot_maxint, calculator = True, option = None, field_name = 'integer', **kwargs): CustomEditor.__init__(self, parent) self.setObjectName( field_name ) action = QtGui.QAction(self) action.setShortcut( QtGui.QKeySequence( Qt.Key_F4 ) ) self.setFocusPolicy(Qt.StrongFocus) self.spinBox = CustomDoubleSpinBox(option, parent) self.spinBox.setRange(minimum, maximum) self.spinBox.setDecimals(0) self.spinBox.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.spinBox.addAction(action) self.spinBox.lineEdit().setText('') self.calculatorButton = QtGui.QToolButton() self.calculatorButton.setIcon(self.calculator_icon.getQIcon()) self.calculatorButton.setAutoRaise(True) self.calculatorButton.setFocusPolicy(Qt.ClickFocus) self.calculatorButton.setFixedHeight(self.get_height()) self.calculatorButton.clicked.connect( lambda:self.popupCalculator(self.spinBox.value()) ) action.triggered.connect( lambda:self.popupCalculator(self.spinBox.value()) ) self.spinBox.editingFinished.connect( self.spinbox_editing_finished ) layout = QtGui.QHBoxLayout() layout.setContentsMargins( 0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self.spinBox) layout.addWidget(self.calculatorButton) self.setFocusProxy(self.spinBox) self.setLayout(layout) self._nullable = True self._calculator = calculator self.option = option
def __init__(self, parent, precision=2, reverse=False, neutral=False, **kwargs): CustomEditor.__init__(self, parent) action = QtGui.QAction(self) action.setShortcut(Qt.Key_F3) self.setFocusPolicy(Qt.StrongFocus) self.spinBox = CustomDoubleSpinBox(parent) self.spinBox.setDecimals(precision) self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.spinBox.addAction(action) self.spinBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons) self.arrow = QtGui.QLabel() self.arrow.setPixmap( Icon('tango/16x16/actions/go-up.png').getQPixmap()) self.arrow.setFixedHeight(self.get_height()) self.arrow.setAutoFillBackground(False) self.arrow.setMaximumWidth(19) self.calculatorButton = QtGui.QToolButton() icon = Icon('tango/16x16/apps/accessories-calculator.png').getQIcon() self.calculatorButton.setIcon(icon) self.calculatorButton.setAutoRaise(True) self.calculatorButton.setFixedHeight(self.get_height()) self.calculatorButton.clicked.connect( lambda: self.popupCalculator(self.spinBox.value())) action.triggered.connect( lambda: self.popupCalculator(self.spinBox.value())) self.spinBox.editingFinished.connect(self.spinbox_editing_finished) self.releaseKeyboard() layout = QtGui.QHBoxLayout() layout.setMargin(0) layout.setSpacing(0) layout.addSpacing(3.5) layout.addWidget(self.arrow) layout.addWidget(self.spinBox) layout.addWidget(self.calculatorButton) self.reverse = reverse self.neutral = neutral self.setFocusProxy(self.spinBox) self.setLayout(layout) if not self.reverse: if not self.neutral: self.icons = { -1: Icon('tango/16x16/actions/go-down-red.png').getQPixmap(), 1: Icon('tango/16x16/actions/go-up.png').getQPixmap(), 0: Icon('tango/16x16/actions/zero.png').getQPixmap() } else: self.icons = { -1: Icon('tango/16x16/actions/go-down-blue.png').getQPixmap(), 1: Icon('tango/16x16/actions/go-up-blue.png').getQPixmap(), 0: Icon('tango/16x16/actions/zero.png').getQPixmap() } else: self.icons = { 1: Icon('tango/16x16/actions/go-down-red.png').getQPixmap(), -1: Icon('tango/16x16/actions/go-up.png').getQPixmap(), 0: Icon('tango/16x16/actions/zero.png').getQPixmap() }
def __init__(self, parent, precision=2, reverse=False, neutral=False, option=None, field_name='float', **kwargs): CustomEditor.__init__(self, parent) self.setObjectName(field_name) action = QtGui.QAction(self) action.setShortcut(QtGui.QKeySequence(Qt.Key_F4)) self.setFocusPolicy(Qt.StrongFocus) self.spinBox = CustomDoubleSpinBox(option, parent) self.spinBox.setDecimals(precision) self.spinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.spinBox.addAction(action) self.spinBox.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons) self.arrow = QtGui.QLabel() self.arrow.setPixmap(self.go_up.getQPixmap()) self.arrow.setFixedHeight(self.get_height()) self.arrow.setAutoFillBackground(False) self.arrow.setMaximumWidth(19) self.calculatorButton = QtGui.QToolButton() self.calculatorButton.setIcon(self.calculator_icon.getQIcon()) self.calculatorButton.setAutoRaise(True) self.calculatorButton.setFixedHeight(self.get_height()) self.calculatorButton.clicked.connect( lambda: self.popupCalculator(self.spinBox.value())) action.triggered.connect( lambda: self.popupCalculator(self.spinBox.value())) self.spinBox.editingFinished.connect(self.spinbox_editing_finished) self.releaseKeyboard() layout = QtGui.QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addSpacing(3.5) layout.addWidget(self.arrow) layout.addWidget(self.spinBox) layout.addWidget(self.calculatorButton) self.reverse = reverse self.neutral = neutral self.setFocusProxy(self.spinBox) self.setLayout(layout) if not self.reverse: if not self.neutral: self.icons = { -1: self.go_down_red, 1: self.go_up, 0: self.zero, } else: self.icons = { -1: self.go_down_blue, 1: self.go_up_blue, 0: self.zero, } else: self.icons = { 1: self.go_down_red, -1: self.go_up, 0: self.zero, }