예제 #1
0
    def __init__(self, *args, **kws):
        #k why was i not allowed to put 'for_a_length = 0' into this arglist??
        for_a_length = kws.pop('for_a_length',0)
        assert not kws, "keyword arguments are not supported by QSpinBox"

        # QSpinBox.__init__(self, *args) #k #e note, if the args can affect the range, we'll mess that up below
        QSpinBox.__init__(self) #k #e note, if the args can affect the range, we'll mess that up below
        assert len(args) is 2
        assert type(args[1]) is type('abc')
        self.setObjectName(args[1])
        qt4warning('QSpinBox() ignoring args: ' + repr(args))

        ## self.setValidator(0) # no keystrokes are prevented from being entered
            ## TypeError: argument 1 of QSpinBox.setValidator() has an invalid type -- hmm, manual didn't think so -- try None? #e

        qt4todo('self.setValidator( QDoubleValidator( - self.range_angstroms, self.range_angstroms, 2, self ))')

            # QDoubleValidator has a bug: it turns 10.2 into 10.19! But mostly it works. Someday we'll need our own. [bruce 041009]
        if not for_a_length:
            self.setRange( - int(self.range_angstroms * self.precision_angstroms),
                             int(self.range_angstroms * self.precision_angstroms) )
        else:
            self.setRange( int(self.min_length * self.precision_angstroms),
                           int(self.max_length * self.precision_angstroms) )
        qt4todo('self.setSteps( self.precision_angstroms, self.precision_angstroms * 10 ) # set linestep and pagestep')
예제 #2
0
    def __init__(self, *args, **kws):
        #k why was i not allowed to put 'for_a_length = 0' into this arglist??
        for_a_length = kws.pop('for_a_length', 0)
        assert not kws, "keyword arguments are not supported by QSpinBox"

        # QSpinBox.__init__(self, *args) #k #e note, if the args can affect the range, we'll mess that up below
        QSpinBox.__init__(
            self
        )  #k #e note, if the args can affect the range, we'll mess that up below
        assert len(args) is 2
        assert type(args[1]) is type('abc')
        self.setObjectName(args[1])
        qt4warning('QSpinBox() ignoring args: ' + repr(args))

        ## self.setValidator(0) # no keystrokes are prevented from being entered
        ## TypeError: argument 1 of QSpinBox.setValidator() has an invalid type -- hmm, manual didn't think so -- try None? #e

        qt4todo(
            'self.setValidator( QDoubleValidator( - self.range_angstroms, self.range_angstroms, 2, self ))'
        )

        # QDoubleValidator has a bug: it turns 10.2 into 10.19! But mostly it works. Someday we'll need our own. [bruce 041009]
        if not for_a_length:
            self.setRange(
                -int(self.range_angstroms * self.precision_angstroms),
                int(self.range_angstroms * self.precision_angstroms))
        else:
            self.setRange(int(self.min_length * self.precision_angstroms),
                          int(self.max_length * self.precision_angstroms))
        qt4todo(
            'self.setSteps( self.precision_angstroms, self.precision_angstroms * 10 ) # set linestep and pagestep'
        )
예제 #3
0
 def __init__(self, parent):
     QSpinBox.__init__(self, parent)
     self.setToolTip(self.TOOLTIP)
     self.setWhatsThis(self.TOOLTIP)
     self.setMaximum(5)
     self.setSuffix(' ' + _('stars'))
예제 #4
0
    def __init__(self,
                 parentWidget,
                 label        = '',
                 labelColumn  = 0,
                 value        = 0,
                 setAsDefault = True,
                 minimum      = 0,
                 maximum      = 99,
                 singleStep   = 1,
                 suffix       = '',
                 spanWidth    = False
                 ):
        """
        Appends a QSpinBox (Qt) widget to the bottom of I{parentWidget},
        a Property Manager group box.

        @param parentWidget: the parent group box containing this widget.
        @type  parentWidget: PM_GroupBox

        @param label: The label that appears to the left of (or above) the
                      spin box. If label contains the relative path to an
                      icon (.png) file, that icon image will be used for the
                      label.

                      If spanWidth is True, the label will be displayed on
                      its own row directly above the spin box.

                      To suppress the label, set I{label} to an empty string.
        @type  label: str

        @param value: The initial value of the spin box.
        @type  value: int

        @param setAsDefault: Determines if the spin box value is reset when
                             the "Restore Defaults" button is clicked. If True,
                             (the default) I{value} will be used as the reset
                             value.
        @type  setAsDefault: bool

        @param minimum: The minimum value of the spin box.
        @type  minimum: int

        @param maximum: The maximum value of the spin box.
        @type  maximum: int

        @param singleStep: When the user uses the arrows to change the
                           spin box's value the value will be
                           incremented/decremented by the amount of the
                           singleStep. The default value is 1.
                           Setting a singleStep value of less than 0 does
                           nothing.
        @type  singleStep: int

        @param suffix: The suffix is appended to the end of the displayed value.
                       Typical use is to display a unit of measurement.
                       The default is no suffix. The suffix is not displayed
                       for the minimum value if specialValueText() is set.
        @type  suffix: str

        @param spanWidth: If True, the spin box and its label will span the
                          width of the group box. The label will appear
                          directly above the spin box and is left justified.
        @type  spanWidth: bool

        @see: U{B{QSpinBox}<http://doc.trolltech.com/4/qspinbox.html>}
        """

        if 0: # Debugging code
            print "PM_SpinBox.__init__():"
            print "  label        = ", label
            print "  labelColumn  = ", labelColumn
            print "  value        = ", value
            print "  setAsDefault = ", setAsDefault
            print "  minimum      = ", minimum
            print "  maximum      = ", maximum
            print "  singleStep   = ", singleStep
            print "  suffix       = ", suffix
            print "  spanWidth    = ", spanWidth

        QSpinBox.__init__(self)

        self.parentWidget = parentWidget
        self.label        = label
        self.labelColumn  = labelColumn
        self.setAsDefault = setAsDefault
        self.spanWidth    = spanWidth

        self._suppress_valueChanged_signal = False

        if label: # Create this widget's QLabel.
            self.labelWidget = QLabel()
            self.labelWidget.setText(label)

        # Set QSpinBox minimum, maximum and initial value
        self.setRange(minimum, maximum)
        self.setSingleStep(singleStep)
        self.setValue(value)

        # Set default value
        self.defaultValue = value
        self.setAsDefault = setAsDefault

        # Add suffix if supplied.
        if suffix:
            self.setSuffix(suffix)

        parentWidget.addPmWidget(self)
예제 #5
0
 def __init__(self, 
              parentWidget, 
              label        = '', 
              labelColumn  = 0,
              value        = 0, 
              setAsDefault = True,
              minimum      = 0, 
              maximum      = 99,
              singleStep   = 1,
              suffix       = '',
              spanWidth    = False
              ):
     """
     Appends a QSpinBox (Qt) widget to the bottom of I{parentWidget}, 
     a Property Manager group box.
     
     @param parentWidget: the parent group box containing this widget.
     @type  parentWidget: PM_GroupBox
     
     @param label: The label that appears to the left of (or above) the 
                   spin box. If label contains the relative path to an 
                   icon (.png) file, that icon image will be used for the
                   label.
                   
                   If spanWidth is True, the label will be displayed on
                   its own row directly above the spin box. 
                   
                   To suppress the label, set I{label} to an empty string.
     @type  label: str
     
     @param value: The initial value of the spin box.
     @type  value: int
     
     @param setAsDefault: Determines if the spin box value is reset when 
                          the "Restore Defaults" button is clicked. If True,
                          (the default) I{value} will be used as the reset 
                          value.
     @type  setAsDefault: bool
     
     @param minimum: The minimum value of the spin box.
     @type  minimum: int
     
     @param maximum: The maximum value of the spin box.
     @type  maximum: int
     
     @param singleStep: When the user uses the arrows to change the 
                        spin box's value the value will be 
                        incremented/decremented by the amount of the 
                        singleStep. The default value is 1. 
                        Setting a singleStep value of less than 0 does 
                        nothing.
     @type  singleStep: int
     
     @param suffix: The suffix is appended to the end of the displayed value. 
                    Typical use is to display a unit of measurement. 
                    The default is no suffix. The suffix is not displayed
                    for the minimum value if specialValueText() is set.
     @type  suffix: str
     
     @param spanWidth: If True, the spin box and its label will span the 
                       width of the group box. The label will appear 
                       directly above the spin box and is left justified. 
     @type  spanWidth: bool
     
     @see: U{B{QSpinBox}<http://doc.trolltech.com/4/qspinbox.html>}
     """
     
     if 0: # Debugging code
         print "PM_SpinBox.__init__():"
         print "  label        = ", label
         print "  labelColumn  = ", labelColumn
         print "  value        = ", value
         print "  setAsDefault = ", setAsDefault
         print "  minimum      = ", minimum
         print "  maximum      = ", maximum
         print "  singleStep   = ", singleStep
         print "  suffix       = ", suffix
         print "  spanWidth    = ", spanWidth
     
     QSpinBox.__init__(self)
             
     self.parentWidget = parentWidget
     self.label        = label
     self.labelColumn  = labelColumn
     self.setAsDefault = setAsDefault
     self.spanWidth    = spanWidth
     
     self._suppress_valueChanged_signal = False
     
     if label: # Create this widget's QLabel.
         self.labelWidget = QLabel()
         self.labelWidget.setText(label)
             
     # Set QSpinBox minimum, maximum and initial value
     self.setRange(minimum, maximum)
     self.setSingleStep(singleStep)
     self.setValue(value)
     
     # Set default value
     self.defaultValue = value
     self.setAsDefault = setAsDefault
     
     # Add suffix if supplied.
     if suffix:
         self.setSuffix(suffix)
         
     parentWidget.addPmWidget(self)
예제 #6
0
 def __init__(self, parent):
     QSpinBox.__init__(self, parent)
     self.setToolTip(self.TOOLTIP)
     self.setWhatsThis(self.TOOLTIP)
     self.setMaximum(5)
     self.setSuffix(' ' + _('stars'))