我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用PySide.QtGui.QSlider()。
def init_middle_pane(self): self.mid_pane = QtGui.QHBoxLayout() # IMGS: images which will display the video preview pixmap = QtGui.QPixmap("0.jpg") pixmap.scaledToWidth(self.preview_size) pixmap.scaledToHeight(self.preview_size) img_lbl = QtGui.QLabel(self) img_lbl.setPixmap(pixmap) # Make sure the window isn't constantly resizing img_lbl.setScaledContents(True) img_lbl.setMaximumWidth(self.preview_size) img_lbl.setMaximumHeight(self.preview_size) self.img = img_lbl self.mid_pane.addWidget(self.img) # SLIDER: slide to rate the quality of the video self.slider = QtGui.QSlider(self, QtCore.Qt.Vertical) self.slider.setTickPosition(QtGui.QSlider.TicksBothSides) self.slider.setTickInterval(20) self.mid_pane.addWidget(self.slider) self.layout.addLayout(self.mid_pane)
def slider_imple(self): """implementation of Edge threshold sliders""" self.EdgeSliderForGraph = QtGui.QSlider(QtCore.Qt.Horizontal,self) self.EdgeSliderForGraph.setTracking(False) self.EdgeSliderForGraph.setRange( self.Graph_data().data.min()*1000 , self.Graph_data().data.max()* 1000 ) self.EdgeSliderForGraph.setValue(self.EdgeSliderValue*1000) self.EdgeSliderForGraph.setToolTip("Edge Weight: %0.2f" % (self.EdgeSliderValue)) self.interval=((0.1-5)/10)*(-1) self.EdgeSliderForGraph.valueChanged[int].connect(self.ChangePropertiesOfGraph)
def __init__(self, templateData, parcelationData, axis, correlationTable, colorTable, selectedColor): super(SliceViewer, self).__init__() self.template = templateData self.regionId = None self.parcelation = parcelationData self.axis = axis self.CommunityMode = False self.correlationTable = correlationTable self.colorTable= colorTable self.selectedColor = selectedColor self.displayedSlice = 0 self.QImage = [] scalefactor = 350 self.scaleFactor = int(math.ceil(scalefactor / self.parcelation.shape[0])) numColors = self.parcelation.max() self.clut = np.zeros(numColors, dtype=np.uint32) for i in range(numColors): r, g, b = colorsys.hls_to_rgb(float(i) / float(numColors), 0.5, 1.0) self.clut[i] = (255 << 24 | int(255*r) << 16 | int(255*g) << 8 | int(255*b)) slice_view_layout = QtGui.QHBoxLayout() self.setLayout(slice_view_layout) slider = QtGui.QSlider() slider.setRange(0, self.template.shape[self.axis]-1) slider.valueChanged.connect(self.setDisplayedSlice) slider.sliderReleased.connect(self.handleSliderRelease) slider.setValue(self.displayedSlice) slice_view_layout.addWidget(slider) self.label = QtGui.QLabel() self.updateSliceLabel() slice_view_layout.addWidget(self.label)
def NodeSlider(self): self.timeStepSlider = QtGui.QSlider(QtCore.Qt.Horizontal,self) self.timeStepSlider.setRange(0, timestep) self.timeStepSlider.setValue(0) self.timeStepSlider.setToolTip("Time Step: %0.2f" % (self.timeStep)) self.timeStepSlider.setTracking(False) self.timeStepSlider.valueChanged[int].connect(self.ChangeValue) self.timeStepSlider.sliderReleased.connect(self.unsetVariables) self.timeStepSlider.hide() # self.timeStepSlider.show()
def create_range_setting(self, name): hlayout = QtGui.QHBoxLayout() setting = self.get_setting(name) button = None if setting.button: button = QtGui.QPushButton(setting.button) button.clicked.connect(lambda: setting.button_callback(button)) slider = QtGui.QSlider(QtCore.Qt.Orientation.Horizontal) slider.setRange(setting.min, setting.max) slider.valueChanged.connect(self.call_with_object('setting_changed', slider, setting)) slider.setMinimumWidth(60) slider.setObjectName(setting.name) slider.setValue(setting.default_value) slider.setStatusTip(setting.description) slider.setToolTip(setting.description) range_label = QtGui.QLabel(str(setting.default_value)) range_label.setMaximumWidth(45) slider.valueChanged.connect(self.call_with_object('_update_range_label', range_label, setting)) w = QtGui.QWidget() whlayout = QtGui.QHBoxLayout() whlayout.addWidget(slider) whlayout.addWidget(range_label) w.setLayout(whlayout) hlayout.addWidget(w) return hlayout
def setupUi(self, Zebra): Zebra.setObjectName(_fromUtf8("Zebra")) Zebra.resize(241, 302) self.verticalLayoutWidget = QtGui.QWidget(Zebra) self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 221, 251)) self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget")) self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.label = QtGui.QLabel(self.verticalLayoutWidget) self.label.setObjectName(_fromUtf8("label")) self.verticalLayout.addWidget(self.label, QtCore.Qt.AlignHCenter) self.horizontalSlider = QtGui.QSlider(self.verticalLayoutWidget) self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider.setObjectName(_fromUtf8("horizontalSlider")) self.verticalLayout.addWidget(self.horizontalSlider) self.label_2 = QtGui.QLabel(self.verticalLayoutWidget) self.label_2.setObjectName(_fromUtf8("label_2")) self.verticalLayout.addWidget(self.label_2, QtCore.Qt.AlignHCenter) self.horizontalSlider_2 = QtGui.QSlider(self.verticalLayoutWidget) self.horizontalSlider_2.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider_2.setObjectName(_fromUtf8("horizontalSlider_2")) self.verticalLayout.addWidget(self.horizontalSlider_2) self.label_3 = QtGui.QLabel(self.verticalLayoutWidget) self.label_3.setObjectName(_fromUtf8("label_3")) self.verticalLayout.addWidget(self.label_3, QtCore.Qt.AlignHCenter) self.horizontalSlider_3 = QtGui.QSlider(self.verticalLayoutWidget) self.horizontalSlider_3.setOrientation(QtCore.Qt.Horizontal) self.horizontalSlider_3.setObjectName(_fromUtf8("horizontalSlider_3")) self.verticalLayout.addWidget(self.horizontalSlider_3) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.pushButton = QtGui.QPushButton(self.verticalLayoutWidget) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.verticalLayout.addWidget(self.pushButton, QtCore.Qt.AlignHCenter) self.retranslateUi(Zebra) # QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("released()")), Zebra.close) # QtCore.QMetaObject.connectSlotsByName(Zebra)
def toggleRelativeFrame(self): sender = self.sender() frame = sender.parent().findChild(QtGui.QLabel, 'frame_number').text() sliderValue = sender.parent().findChild(QtGui.QSlider, 'frame_opacity_slider').value() if sender.isChecked(): onionCore.viewRenderOverrideInstance.addRelativeOnion(frame, sliderValue) else: onionCore.viewRenderOverrideInstance.removeRelativeOnion(frame) #
def toggleAbsoluteFrame(self): sender = self.sender() frame = sender.parent().findChild(QtGui.QLabel, 'frame_number').text() sliderValue = sender.parent().findChild(QtGui.QSlider, 'frame_opacity_slider').value() if sender.isChecked(): onionCore.viewRenderOverrideInstance.addAbsoluteOnion(frame, sliderValue) else: onionCore.viewRenderOverrideInstance.removeAbsoluteOnion(frame) #
def set_dip_count(self, number): for i in range(number): dip = QSlider(self) dip.setMinimum(0) dip.setMaximum(1) dip.valueChanged.connect(self.__on_changed) self._layout.addWidget(dip) self._dips.append(dip)
def dialog(sk=None): if sk==None: [sk]=Gui.Selection.getSelection() if 1: w=QtGui.QWidget() w.sk=sk w.texts=[] tc=sk.ViewObject.LineColor color=colors.rgb2hex(sk.ViewObject.LineColor) invers=(1.0-tc[0],1.0-tc[1],1.0-tc[2]) icolor=colors.rgb2hex(invers) mcolor='#808080' w.setStyleSheet("QWidget { background-color:"+color+"}\ QPushButton { margin-right:0px;margin-left:0px;margin:0 px;padding:0px;;\ background-color:#ccc;text-align:left;;padding:6px;padding-left:4px;color:#333; }") box = QtGui.QVBoxLayout() w.setLayout(box) w.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) l=QtGui.QLabel(sk.Label) l.setText( '<font color='+icolor+'>'+sk.Label+'</font>' ) box.addWidget(l) w.box=[] for i,c in enumerate(sk.Constraints): print (c.Name,c.Value) if c.Name.startswith("Weight"): l=QtGui.QLabel(c.Name) l.setText( '<font color='+icolor+'>'+c.Name+'</font>' ) box.addWidget(l) d=QtGui.QSlider(QtCore.Qt.Horizontal) d.c=c d.i=i box.addWidget(d) d.setValue(c.Value-1) d.setMaximum(100) d.setMinimum(0) d.valueChanged.connect(lambda:wrun(w)) w.box.append(d) w.r=QtGui.QPushButton("close") box.addWidget(w.r) w.r.pressed.connect(lambda :runex(w)) wrun(w) w.show() return w