本文整理匯總了Python中PySide.QtGui.QSlider類的典型用法代碼示例。如果您正苦於以下問題:Python QSlider類的具體用法?Python QSlider怎麽用?Python QSlider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了QSlider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MultiVolumeVisualizationMIP
class MultiVolumeVisualizationMIP(MultiVolumeVisualization):
"""
MultiVolumeVisualizationMIP is a visualization that shows
MIP visualizations of both datasets and adds them
together. It uses complementary colors for the datasets
so that the visualization is white in the spots where
they are the same.
"""
def __init__(self):
super(MultiVolumeVisualizationMIP, self).__init__()
self.fixedHue = 0
@overrides(MultiVolumeVisualization)
def getParameterWidget(self):
self.hueSlider = QSlider(Qt.Horizontal)
self.hueSlider.setMaximum(360)
self.hueSlider.setValue(self.fixedHue)
self.hueSlider.valueChanged.connect(self.valueChanged)
layout = QGridLayout()
layout.setAlignment(Qt.AlignTop)
layout.addWidget(QLabel("Base hue"), 0, 0)
layout.addWidget(self.hueSlider, 0, 1)
widget = QWidget()
widget.setLayout(layout)
return widget
@overrides(MultiVolumeVisualization)
def setImageData(self, fixedImageData, movingImageData):
self.fixedImageData = fixedImageData
self.movingImageData = movingImageData
@overrides(MultiVolumeVisualization)
def updateTransferFunctions(self):
self.fixedVolProp = self._createVolPropFromImageData(self.fixedImageData)
self.movingVolProp = self._createVolPropFromImageData(self.movingImageData)
self.updatedTransferFunction.emit()
@overrides(MultiVolumeVisualization)
def valueChanged(self, value):
self.fixedHue = self.hueSlider.value()
self.updateTransferFunctions()
@overrides(MultiVolumeVisualization)
def setMapper(self, mapper):
self.mapper = mapper
def _createVolPropFromImageData(self, imageData):
volProp = vtkVolumeProperty()
if imageData is not None:
color, opacityFunction = CreateRangeFunctions(imageData)
else:
color, opacityFunction = CreateEmptyFunctions()
volProp.SetColor(color)
volProp.SetScalarOpacity(opacityFunction)
return volProp
示例2: getParameterWidget
def getParameterWidget(self):
"""
Returns a widget with sliders / fields with which properties of this
volume property can be adjusted.
:rtype: QWidget
"""
layout = QGridLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setAlignment(Qt.AlignTop)
self.sliders = []
for index in range(7):
slider = QSlider(Qt.Horizontal)
slider.setMinimum(0)
slider.setMaximum(1000)
slider.setValue(int(math.pow(self.sectionsOpacity[index], 1.0/3.0) * slider.maximum()))
slider.valueChanged.connect(self.valueChanged)
self.sliders.append(slider)
label = QLabel(self.sectionNames[index])
label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
layout.addWidget(label, index, 0)
layout.addWidget(slider, index, 1)
try:
from ColumnResizer import ColumnResizer
columnResizer = ColumnResizer()
columnResizer.addWidgetsFromLayout(layout, 0)
except Exception, e:
print e
示例3: initUi
def initUi(self):
#slider
slider = QSlider(PySide.QtCore.Qt.Orientation.Horizontal, self)
slider.setRange(0,2)
slider.setTickInterval(1)
slider.setValue(2)
self.slider = slider
#.. and corresponding label element
label = QLabel(self)
label.setText(self.activation_states[slider.value()])
self.label = label
#connections
#PySide.QtCore.QObject.connect(slider, slider.valueChanged, self, self.update_label)
#self.connect(slider.valueChanged, self.update_label())
slider.valueChanged[int].connect(self.update_label)
# layout
lo = QVBoxLayout()
lo.addWidget( slider )
lo.addWidget( label )
self.setLayout(lo)
示例4: _buildSetupPanel
def _buildSetupPanel(self):
'''
Creates the sub-panel containing control widgets for re-initializing
the world on demand.
'''
self._percentLbl = QLabel("%")
self._setupBtn = QPushButton("Setup", self._window)
self._setupBtn.clicked.connect(self._onSetup)
self._percentObstacleSldr = QSlider(Qt.Horizontal, self._window)
self._percentObstacleSldr.setTickPosition(QSlider.TickPosition.TicksBelow)
self._percentObstacleSldr.setTickInterval(10)
self._percentObstacleSldr.setMinimum(0)
self._percentObstacleSldr.setMaximum(100)
self._percentObstacleSldr.valueChanged.connect(self._onPercentSlideChange)
self._percentObstacleSldr.setValue(33)
layout = QGridLayout()
layout.addWidget(self._setupBtn, 0, 0, 1, 2)
layout.addWidget(QLabel("Percent Occupied:"), 1, 0)
layout.addWidget(self._percentLbl, 1, 1)
layout.addWidget(self._percentObstacleSldr, 2, 0, 1, 2)
grpBx = QGroupBox("Setup Controls")
grpBx.setLayout(layout)
grpBx.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
return grpBx
示例5: createDisplayFields
def createDisplayFields(self):
display_widget = QFrame()
display_widget.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
self.left_layout.addWidget(display_widget)
self.display_layout = QHBoxLayout()
# self.turn = self.transcript.current_turn()
self.time_field = qHotField("time", str, "00:00:00", min_size=75, max_size=75, pos="top", handler=self.update_time)
self.display_layout.addWidget(self.time_field)
self.speaker_field = qHotField("speaker", str, " ", min_size=75, max_size=75, pos="top", handler=self.update_speaker)
self.display_layout.addWidget(self.speaker_field)
self.utt_field = qHotField("utterance", str, " ", min_size=350, max_size=500, pos="top", handler=self.update_utterance, multiline=True)
self.utt_field.setStyleSheet("font: 14pt \"Courier\";")
# self.utt_field.efield.setFont(QFont('SansSerif', 12))
self.display_layout.addWidget(self.utt_field)
display_widget.setLayout(self.display_layout)
self.display_layout.setStretchFactor(self.speaker_field, 0)
self.display_layout.setStretchFactor(self.utt_field, 1)
self.transcript_slider = QSlider(QtCore.Qt.Horizontal, self)
self.display_layout.addWidget(self.transcript_slider)
self.transcript_slider.setMaximum(100)
self.connect(self.transcript_slider,
QtCore.SIGNAL("sliderMoved(int)"), self.position_transcript)
self.left_layout.addWidget(self.transcript_slider)
示例6: __init__
def __init__(self, text, minValue, maxValue, defaultValue ):
QWidget.__init__( self )
validator = QDoubleValidator(minValue, maxValue, 2, self )
mainLayout = QHBoxLayout( self )
checkBox = QCheckBox()
checkBox.setFixedWidth( 115 )
checkBox.setText( text )
lineEdit = QLineEdit()
lineEdit.setValidator( validator )
lineEdit.setText( str(defaultValue) )
slider = QSlider( QtCore.Qt.Horizontal )
slider.setMinimum( minValue*100 )
slider.setMaximum( maxValue*100 )
slider.setValue( defaultValue )
mainLayout.addWidget( checkBox )
mainLayout.addWidget( lineEdit )
mainLayout.addWidget( slider )
QtCore.QObject.connect( slider, QtCore.SIGNAL( 'valueChanged(int)' ), self.syncWidthLineEdit )
QtCore.QObject.connect( lineEdit, QtCore.SIGNAL( 'textChanged(QString)' ), self.syncWidthSlider )
QtCore.QObject.connect( checkBox, QtCore.SIGNAL( "clicked()" ), self.updateEnabled )
self.checkBox = checkBox
self.slider = slider
self.lineEdit = lineEdit
self.updateEnabled()
示例7: __init__
def __init__(self, *args, **kwargs ):
self.minimum = 1
self.maximum = 100
self.lineEditMaximum = 10000
QMainWindow.__init__( self, *args, **kwargs )
self.installEventFilter( self )
#self.setWindowFlags( QtCore.Qt.Drawer )
self.setWindowTitle( Window_global.title )
widgetMain = QWidget()
layoutVertical = QVBoxLayout( widgetMain )
self.setCentralWidget( widgetMain )
layoutSlider = QHBoxLayout()
lineEdit = QLineEdit(); lineEdit.setFixedWidth( 100 )
lineEdit.setText( str( 1 ) )
validator = QIntValidator(self.minimum, self.lineEditMaximum, self)
lineEdit.setValidator( validator )
slider = QSlider(); slider.setOrientation( QtCore.Qt.Horizontal )
slider.setMinimum( self.minimum )
slider.setMaximum( self.maximum )
layoutSlider.addWidget( lineEdit )
layoutSlider.addWidget( slider )
layoutAngle = QVBoxLayout()
checkBox = QCheckBox( 'Connect Angle By Tangent' )
layoutVector = QHBoxLayout()
leVx = QLineEdit(); leVx.setText( str( 1.000 ) ); leVx.setEnabled( False )
leVx.setValidator( QDoubleValidator( -100, 100, 5, self ) )
leVy = QLineEdit(); leVy.setText( str( 0.000 ) ); leVy.setEnabled( False )
leVy.setValidator( QDoubleValidator( -100, 100, 5, self ) )
leVz = QLineEdit(); leVz.setText( str( 0.000 ) ); leVz.setEnabled( False )
leVz.setValidator( QDoubleValidator( -100, 100, 5, self ) )
layoutAngle.addWidget( checkBox )
layoutAngle.addLayout( layoutVector )
layoutVector.addWidget( leVx ); layoutVector.addWidget( leVy ); layoutVector.addWidget( leVz )
button = QPushButton( 'Create' )
layoutVertical.addLayout( layoutSlider )
layoutVertical.addLayout( layoutAngle )
layoutVertical.addWidget( button )
QtCore.QObject.connect( slider, QtCore.SIGNAL('valueChanged(int)'), self.sliderValueChanged )
QtCore.QObject.connect( lineEdit, QtCore.SIGNAL('textEdited(QString)'), self.lineEditValueChanged )
QtCore.QObject.connect( button, QtCore.SIGNAL('clicked()'), Functions.createPointOnCurve )
QtCore.QObject.connect( checkBox, QtCore.SIGNAL( 'clicked()'), Functions.setAngleEnabled )
self.slider = slider
self.lineEdit = lineEdit
Window_global.slider = slider
Window_global.button = button
Window_global.checkBox = checkBox
Window_global.leVx = leVx
Window_global.leVy = leVy
Window_global.leVz = leVz
示例8: SliderWidget
class SliderWidget(QWidget):
"""
SliderWidget
"""
valueChanged = Signal(int)
def __init__(self):
super(SliderWidget, self).__init__()
self.label = QLabel()
self.slider = QSlider(Qt.Horizontal)
self.spinbox = QSpinBox()
self.slider.valueChanged.connect(self.changedValue)
self.spinbox.valueChanged.connect(self.changedValue)
layout = QGridLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setVerticalSpacing(0)
layout.addWidget(self.label, 0, 0)
layout.addWidget(self.slider, 0, 1)
layout.addWidget(self.spinbox, 0, 2)
self.setLayout(layout)
def setName(self, name):
"""
Set the name for the slider
"""
self.label.setText(name)
def setRange(self, range):
"""
Set the range for the value
"""
self.slider.setMinimum(range[0])
self.spinbox.setMinimum(range[0])
self.slider.setMaximum(range[1])
self.spinbox.setMaximum(range[1])
def setValue(self, value):
"""
Set the value for the slider and the spinbox
"""
self.slider.setValue(value)
self.spinbox.setValue(value)
def value(self):
return self.slider.value()
@Slot(int)
def changedValue(self, value):
self.setValue(value)
self.valueChanged.emit(value)
示例9: NumericBox
class NumericBox(QFrame):
"""
A box with a spinner and a slider to allow easier value manipulation by user
"""
valueChanged = Signal(float)
spinner = QDoubleSpinBox
step = 0.1
def __init__(self, parent=None):
super(NumericBox, self).__init__(parent)
self.slider = QSlider(Qt.Horizontal)
self.spinner = self.spinner()
self.spinner.setSingleStep(self.step)
self.slider.setTickInterval(self.step * 100)
self.slider.setSingleStep(self.step * 100)
self.slider.sliderMoved.connect(lambda x: self.spinner.setValue(x / 100))
self.spinner.valueChanged.connect(self.applyValue)
self.setLayout(line(self.slider, self.spinner))
self.layout().setStretch(1, 0)
def applyValue(self, value):
self.valueChanged.emit(value)
self.slider.setValue(value * 100)
def setValue(self, value):
self.spinner.setValue(value)
self.slider.setValue(value * 100)
def setRange(self, mini, maxi):
self.spinner.setRange(mini, maxi)
self.slider.setRange(mini * 100, maxi * 100)
def value(self):
return self.spinner.value()
示例10: getParameterWidget
def getParameterWidget(self):
self.hueSlider = QSlider(Qt.Horizontal)
self.hueSlider.setMaximum(360)
self.hueSlider.setValue(self.fixedHue)
self.hueSlider.valueChanged.connect(self.valueChanged)
layout = QGridLayout()
layout.setAlignment(Qt.AlignTop)
layout.addWidget(QLabel("Base hue"), 0, 0)
layout.addWidget(self.hueSlider, 0, 1)
widget = QWidget()
widget.setLayout(layout)
return widget
示例11: __init__
def __init__(self, parent=None):
super(NumericBox, self).__init__(parent)
self.slider = QSlider(Qt.Horizontal)
self.spinner = self.spinner()
self.spinner.setSingleStep(self.step)
self.slider.setTickInterval(self.step * 100)
self.slider.setSingleStep(self.step * 100)
self.slider.sliderMoved.connect(lambda x: self.spinner.setValue(x / 100))
self.spinner.valueChanged.connect(self.applyValue)
self.setLayout(line(self.slider, self.spinner))
self.layout().setStretch(1, 0)
示例12: __init__
def __init__(self):
super(SliderWidget, self).__init__()
self.label = QLabel()
self.slider = QSlider(Qt.Horizontal)
self.spinbox = QSpinBox()
self.slider.valueChanged.connect(self.changedValue)
self.spinbox.valueChanged.connect(self.changedValue)
layout = QGridLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setVerticalSpacing(0)
layout.addWidget(self.label, 0, 0)
layout.addWidget(self.slider, 0, 1)
layout.addWidget(self.spinbox, 0, 2)
self.setLayout(layout)
示例13: __init__
def __init__(self, parent=None, name=None):
QWidget.__init__(self, parent)
self.name = name
self.set_format('.3f')
# create widgets
self.label = QLabel()
self.slider = QSlider(QtCore.Qt.Orientation.Horizontal)
self.slider.valueChanged.connect(self._update_label)
# set default values
self.set_range(0, 100)
self.set_value(50)
# create layout for the entire widget
box = QVBoxLayout()
box.addWidget(self.label)
box.addWidget(self.slider)
self.setLayout(box)
示例14: __init__
def __init__(self):
super(SliderFloatWidget, self).__init__()
self.label = QLabel()
self.slider = QSlider(Qt.Horizontal)
self.spinbox = QDoubleSpinBox()
self.slider.valueChanged.connect(self.changedValueFromSlider)
self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)
# Keep track of whether one of the values was changed
# By setting the value of the slider and the spinbox, valueChanged
# events are fired. These events have to be ignored
self._changed = False
layout = QGridLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setVerticalSpacing(0)
layout.addWidget(self.label, 0, 0)
layout.addWidget(self.slider, 0, 1)
layout.addWidget(self.spinbox, 0, 2)
self.setLayout(layout)
示例15: __init__
def __init__(self):
super(Layer, self).__init__()
self.orientation = Quaternion()
self.picked = None
self.show = QCheckBox()
self.show.setChecked(True)
self.alpha_slider = QSlider(QtCore.Qt.Orientation.Horizontal)
self.alpha_slider.setRange(0, 1024)
self.alpha_slider.setValue(1024)
self.alpha_number = QDoubleSpinBox()
self.alpha_number.setDecimals(3)
self.alpha_number.setSingleStep(0.01)
self.alpha_number.setRange(0, 1)
self.alpha_number.setValue(1)
self.alpha_slider.valueChanged.connect(self._alphaSliderChanged)
self.alpha_number.valueChanged.connect(self._alphaNumberChanged)
self.move = QCheckBox()
self.move.setChecked(True)
self.quat = QLineEdit()
font = QFont('monospace')
font.setStyleHint(QFont.TypeWriter)
self.quat.setFont(font)
default_quat = '+0.000, +1.000, +0.000, +0.000'
margins = self.quat.textMargins()
self.quat.setFixedWidth(
# HACK -------------------------------------------v
QFontMetrics(self.quat.font()).width(default_quat + ' ') +
margins.left() + margins.right()
)
self.quat.setInputMask('#0.000, #0.000, #0.000, #0.000')
self.quat.setMaxLength(30)
self.quat.setText(default_quat)
self.quat.editingFinished.connect(self._orientationChanged)
self.nbytes = QLabel()
self.nbytes.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.nbytes.setText('0')
self.label = QLabel()
self.label.setText('<empty>')