本文整理汇总了Python中PySide.QtGui.QSlider.setTickPosition方法的典型用法代码示例。如果您正苦于以下问题:Python QSlider.setTickPosition方法的具体用法?Python QSlider.setTickPosition怎么用?Python QSlider.setTickPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QSlider
的用法示例。
在下文中一共展示了QSlider.setTickPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
def __init__(self, parent, North="Up", East="Right", South="Down", West="Left",BoxLabel='Power', valueName='Position'):
QWidget.__init__(self)
self.North = North
self.East= East
self.South = South
self.West = West
self.boxLabel = BoxLabel
buttonLayout = QGridLayout(self)
northButton = QPushButton(self.North, self)
# northbutton.click(actionscript)
eastButton = QPushButton(self.East, self)
southButton = QPushButton(self.South, self)
westButton = QPushButton(self.West, self)
speedSlider = QSlider()
speedSlider.setTickPosition(QSlider.TicksRight)
speedSlider.setTickInterval(10)
speedSlider.TicksRight
sliderPosition = QSpinBox()
sliderPosition.setRange(0,101)
sliderLabel = QLabel(self.boxLabel)
speedSlider.valueChanged.connect(sliderPosition.setValue)
sliderPosition.valueChanged.connect(speedSlider.setValue)
SliderValue = speedSlider.value()
speedSlider.valueChanged.connect(self.printValue)
#Needs work to fix the layout issues......
buttonLayout.addWidget(northButton, 1, 1)
buttonLayout.addWidget(eastButton, 2, 2)
buttonLayout.addWidget(westButton, 2, 0)
buttonLayout.addWidget(southButton, 3, 1)
buttonLayout.addWidget(sliderPosition,1, 3)
buttonLayout.addWidget(sliderLabel, 0, 3)
buttonLayout.addWidget(speedSlider, 2, 3, 3,3)
self.setLayout(buttonLayout)
示例2: MainWindow
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
#.........这里部分代码省略.........
elif error == QNetworkSession.SessionAbortedError:
msgBox = QMessageBox(self.parent())
msgBox.setText('Out of range of network')
msgBox.setInformativeText('Move back into range and press Retry, or press Cancel to quit the application')
msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel)
msgBox.setIcon(QMessageBox.Information)
msgBox.setDefaultButton(QMessageBox.Retry)
ret = msgBox.exec_()
if ret == QMessageBox.Retry:
QTimer.singleShot(0, self.session.open)
elif ret == QMessageBox.Cancel:
self.close()
def setupUi(self):
scene = QGraphicsScene(self)
self.view = QGraphicsView(scene, self)
self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.view.setVisible(True)
self.view.setInteractive(True)
self.createPixmapIcon()
self.mapWidget = MapWidget(self.mapManager)
scene.addItem(self.mapWidget)
self.mapWidget.setCenter(QGeoCoordinate(-8.1, -34.95))
self.mapWidget.setZoomLevel(5)
#...
self.slider = QSlider(Qt.Vertical, self)
self.slider.setTickInterval(1)
self.slider.setTickPosition(QSlider.TicksBothSides)
self.slider.setMaximum(self.mapManager.maximumZoomLevel())
self.slider.setMinimum(self.mapManager.minimumZoomLevel())
self.slider.valueChanged[int].connect(self.sliderValueChanged)
self.mapWidget.zoomLevelChanged[float].connect(self.mapZoomLevelChanged)
mapControlLayout = QVBoxLayout()
self.mapWidget.mapTypeChanged.connect(self.mapTypeChanged)
for mapType in self.mapWidget.supportedMapTypes():
radio = QRadioButton(self)
if mapType == QGraphicsGeoMap.StreetMap:
radio.setText('Street')
elif mapType == QGraphicsGeoMap.SatelliteMapDay:
radio.setText('Sattelite')
elif mapType == QGraphicsGeoMap.SatelliteMapNight:
radio.setText('Sattelite - Night')
elif mapType == QGraphicsGeoMap.TerrainMap:
radio.setText('Terrain')
if mapType == self.mapWidget.mapType():
radio.setChecked(True)
radio.toggled[bool].connect(self.mapTypeToggled)
self.mapControlButtons.append(radio)
self.mapControlTypes.append(mapType)
mapControlLayout.addWidget(radio)
self.latitudeEdit = QLineEdit()
self.longitudeEdit = QLineEdit()
示例3: PlotMainWindow
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
class PlotMainWindow(QWidget):
"""Base class for plot main windows."""
def __init__(self, U, plot, length=1, title=None):
super(PlotMainWindow, self).__init__()
layout = QVBoxLayout()
if title:
title = QLabel('<b>' + title + '</b>')
title.setAlignment(Qt.AlignHCenter)
layout.addWidget(title)
layout.addWidget(plot)
plot.set(U, 0)
if length > 1:
hlayout = QHBoxLayout()
self.slider = QSlider(Qt.Horizontal)
self.slider.setMinimum(0)
self.slider.setMaximum(length - 1)
self.slider.setTickPosition(QSlider.TicksBelow)
hlayout.addWidget(self.slider)
lcd = QLCDNumber(m.ceil(m.log10(length)))
lcd.setDecMode()
lcd.setSegmentStyle(QLCDNumber.Flat)
hlayout.addWidget(lcd)
layout.addLayout(hlayout)
hlayout = QHBoxLayout()
toolbar = QToolBar()
self.a_play = QAction(self.style().standardIcon(QStyle.SP_MediaPlay), 'Play', self)
self.a_play.setCheckable(True)
self.a_rewind = QAction(self.style().standardIcon(QStyle.SP_MediaSeekBackward), 'Rewind', self)
self.a_toend = QAction(self.style().standardIcon(QStyle.SP_MediaSeekForward), 'End', self)
self.a_step_backward = QAction(self.style().standardIcon(QStyle.SP_MediaSkipBackward),
'Step Back', self)
self.a_step_forward = QAction(self.style().standardIcon(QStyle.SP_MediaSkipForward), 'Step', self)
self.a_loop = QAction(self.style().standardIcon(QStyle.SP_BrowserReload), 'Loop', self)
self.a_loop.setCheckable(True)
toolbar.addAction(self.a_play)
toolbar.addAction(self.a_rewind)
toolbar.addAction(self.a_toend)
toolbar.addAction(self.a_step_backward)
toolbar.addAction(self.a_step_forward)
toolbar.addAction(self.a_loop)
if hasattr(self, 'save'):
self.a_save = QAction(self.style().standardIcon(QStyle.SP_DialogSaveButton), 'Save', self)
toolbar.addAction(self.a_save)
self.a_save.triggered.connect(self.save)
hlayout.addWidget(toolbar)
self.speed = QSlider(Qt.Horizontal)
self.speed.setMinimum(0)
self.speed.setMaximum(100)
hlayout.addWidget(QLabel('Speed:'))
hlayout.addWidget(self.speed)
layout.addLayout(hlayout)
self.timer = QTimer()
self.timer.timeout.connect(self.update_solution)
self.slider.valueChanged.connect(self.slider_changed)
self.slider.valueChanged.connect(lcd.display)
self.speed.valueChanged.connect(self.speed_changed)
self.a_play.toggled.connect(self.toggle_play)
self.a_rewind.triggered.connect(self.rewind)
self.a_toend.triggered.connect(self.to_end)
self.a_step_forward.triggered.connect(self.step_forward)
self.a_step_backward.triggered.connect(self.step_backward)
self.speed.setValue(50)
elif hasattr(self, 'save'):
hlayout = QHBoxLayout()
toolbar = QToolBar()
self.a_save = QAction(self.style().standardIcon(QStyle.SP_DialogSaveButton), 'Save', self)
toolbar.addAction(self.a_save)
hlayout.addWidget(toolbar)
layout.addLayout(hlayout)
self.a_save.triggered.connect(self.save)
self.setLayout(layout)
self.plot = plot
self.U = U
self.length = length
def slider_changed(self, ind):
self.plot.set(self.U, ind)
def speed_changed(self, val):
self.timer.setInterval(val * 20)
def update_solution(self):
ind = self.slider.value() + 1
#.........这里部分代码省略.........
示例4: MainWindow
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
class MainWindow(QWidget):
def __init__(self, grid, U):
assert isinstance(U, Communicable)
super(MainWindow, self).__init__()
U = U.data
layout = QVBoxLayout()
plotBox = QHBoxLayout()
plot = GlumpyPatchWidget(self, grid, vmin=np.min(U), vmax=np.max(U), bounding_box=bounding_box, codim=codim)
bar = ColorBarWidget(self, vmin=np.min(U), vmax=np.max(U))
plotBox.addWidget(plot)
plotBox.addWidget(bar)
layout.addLayout(plotBox)
if len(U) == 1:
plot.set(U.ravel())
else:
plot.set(U[0])
hlayout = QHBoxLayout()
self.slider = QSlider(Qt.Horizontal)
self.slider.setMinimum(0)
self.slider.setMaximum(len(U) - 1)
self.slider.setTickPosition(QSlider.TicksBelow)
hlayout.addWidget(self.slider)
lcd = QLCDNumber(m.ceil(m.log10(len(U))))
lcd.setDecMode()
lcd.setSegmentStyle(QLCDNumber.Flat)
hlayout.addWidget(lcd)
layout.addLayout(hlayout)
hlayout = QHBoxLayout()
toolbar = QToolBar()
self.a_play = QAction(self.style().standardIcon(QStyle.SP_MediaPlay), 'Play', self)
self.a_play.setCheckable(True)
self.a_rewind = QAction(self.style().standardIcon(QStyle.SP_MediaSeekBackward), 'Rewind', self)
self.a_toend = QAction(self.style().standardIcon(QStyle.SP_MediaSeekForward), 'End', self)
self.a_step_backward = QAction(self.style().standardIcon(QStyle.SP_MediaSkipBackward), 'Step Back', self)
self.a_step_forward = QAction(self.style().standardIcon(QStyle.SP_MediaSkipForward), 'Step', self)
self.a_loop = QAction(self.style().standardIcon(QStyle.SP_BrowserReload), 'Loop', self)
self.a_loop.setCheckable(True)
toolbar.addAction(self.a_play)
toolbar.addAction(self.a_rewind)
toolbar.addAction(self.a_toend)
toolbar.addAction(self.a_step_backward)
toolbar.addAction(self.a_step_forward)
toolbar.addAction(self.a_loop)
hlayout.addWidget(toolbar)
self.speed = QSlider(Qt.Horizontal)
self.speed.setMinimum(0)
self.speed.setMaximum(100)
hlayout.addWidget(QLabel('Speed:'))
hlayout.addWidget(self.speed)
layout.addLayout(hlayout)
self.timer = QTimer()
self.timer.timeout.connect(self.update_solution)
self.slider.valueChanged.connect(self.slider_changed)
self.slider.valueChanged.connect(lcd.display)
self.speed.valueChanged.connect(self.speed_changed)
self.a_play.toggled.connect(self.toggle_play)
self.a_rewind.triggered.connect(self.rewind)
self.a_toend.triggered.connect(self.to_end)
self.a_step_forward.triggered.connect(self.step_forward)
self.a_step_backward.triggered.connect(self.step_backward)
self.speed.setValue(50)
self.setLayout(layout)
self.plot = plot
self.U = U
def slider_changed(self, ind):
self.plot.set(self.U[ind])
def speed_changed(self, val):
self.timer.setInterval(val * 20)
def update_solution(self):
ind = self.slider.value() + 1
if ind >= len(self.U):
if self.a_loop.isChecked():
ind = 0
else:
self.a_play.setChecked(False)
return
self.slider.setValue(ind)
def toggle_play(self, checked):
if checked:
if self.slider.value() + 1 == len(self.U):
#.........这里部分代码省略.........
示例5: MainWindow
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
class MainWindow(object):
'''
Contains the implementation for building and displaying the
application's main window.
'''
def __init__(self, model, alg):
'''
Constructs the GUI and initializes internal parameters.
'''
self._window = QMainWindow()
self._window.setWindowTitle("Reverse A*")
self._worldWidget = WorldWidget(model, alg)
self._model = model
self._alg = alg
self._spdSetting = 0
self._timer = QTimer()
#Every time the timer times out, invoke the _onStep method.
self._timer.timeout.connect(self._onStep)
self._buildGUI()
self._window.show()
def _buildGUI(self):
'''
Construct the GUI widgets and layouts.
'''
centerWidget = QWidget()
self._window.setCentralWidget(centerWidget)
worldLayout = QHBoxLayout()
worldLayout.addWidget(self._worldWidget)
grpBx = QGroupBox("2D World")
grpBx.setLayout(worldLayout)
grpBx.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
ctrlPan = self._buildControlPanel()
layout = QHBoxLayout()
layout.addWidget(ctrlPan)
layout.addWidget(grpBx)
layout.setAlignment(ctrlPan, Qt.AlignLeft | Qt.AlignTop)
centerWidget.setLayout(layout)
def _buildControlPanel(self):
'''
Create all buttons, labels, etc for the application control elements
'''
layout = QVBoxLayout()
layout.addWidget(self._buildSetupPanel())
layout.addWidget(self._buildSpeedPanel())
layout.addWidget(self._buildResultsPanel())
layout.addWidget(self._buildRenderingOptions())
layout.setAlignment(Qt.AlignLeft | Qt.AlignTop)
ctrlWidget = QWidget(self._window)
ctrlWidget.setLayout(layout)
ctrlWidget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
return ctrlWidget
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
def _buildSpeedPanel(self):
'''
Creates the sub-panel containing control widgets for controlling the
speed of execution of the algorithm.
'''
self._runBtn = QPushButton("Run", self._window)
self._stepBtn = QPushButton("Step Once", self._window)
self._runBtn.clicked.connect(self._onRun)
self._stepBtn.clicked.connect(self._onStep)
slowRadio = QRadioButton('Slow', self._window)
medRadio = QRadioButton('Medium', self._window)
fastRadio = QRadioButton('Fast', self._window)
#.........这里部分代码省略.........
示例6: EegCarDashboardWindow
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
#.........这里部分代码省略.........
self.dashboard.set_backward_max_throttle(DEFAULT_MAX_BACK_THROTTLE)
self.layout = QVBoxLayout(self)
# Drive Setting
self.rc_mode = QCheckBox('Remote Control', self)
self.rc_mode.stateChanged.connect(self.remote_control)
self.rc_stright_mode = QCheckBox('RC Stright', self)
self.rc_stright_mode.stateChanged.connect(self.stright_control)
self.keep_mode_checkbox = QCheckBox('Keep Mode', self)
self.keep_mode_checkbox.stateChanged.connect(self.keep_mode_control)
self.power_handle_mode_checkbox = QCheckBox('Power Handle', self)
self.power_handle_mode_checkbox.stateChanged.connect(self.power_handle_mode_control)
self.ignore_eeg_input = QCheckBox('Ignore Eeg Input', self)
self.ignore_eeg_input.stateChanged.connect(self.ignore_eeg_input_control)
drive_layout = QHBoxLayout(self)
drive_layout.addWidget(self.rc_mode)
drive_layout.addWidget(self.rc_stright_mode)
drive_layout.addWidget(self.keep_mode_checkbox)
drive_layout.addWidget(self.power_handle_mode_checkbox)
drive_layout.addWidget(self.ignore_eeg_input)
drive_groupbox = QtGui.QGroupBox("Drive Status & Setting")
drive_groupbox.setLayout(drive_layout)
# Throttle Setting
self.throttle_slider = QSlider(Qt.Horizontal)
self.throttle_slider.setFocusPolicy(Qt.StrongFocus)
self.throttle_slider.setTickPosition(QSlider.TicksBothSides)
self.throttle_slider.setTickInterval(10)
self.throttle_slider.setSingleStep(10)
self.throttle_slider.setValue(DEFAULT_MAX_THROTTLE)
self.throttle_slider.valueChanged.connect(self.throttle_slider.setValue)
self.connect(self.throttle_slider, SIGNAL("valueChanged(int)"), self.setSliderMaxThrottle)
self.throttle_label = QLabel('Max Throttle (%): ', self)
self.maxThrottle = QLineEdit(str(DEFAULT_MAX_THROTTLE))
# self.maxThrottle.textChanged[str].connect(self.setMaxThrottle)
self.maxThrottle.editingFinished.connect(self.setMaxThrottle)
self.maxThrottle.setMaxLength(2)
self.maxThrottle.setMaximumWidth(40)
self.backwardMaxThrottle = QLineEdit(str(DEFAULT_MAX_BACK_THROTTLE))
# self.maxThrottle.textChanged[str].connect(self.setMaxThrottle)
self.backwardMaxThrottle.editingFinished.connect(self.setBackwardMaxThrottle)
self.backwardMaxThrottle.setMaxLength(2)
self.backwardMaxThrottle.setMaximumWidth(40)
throttle_layout = QHBoxLayout(self)
throttle_layout.addWidget(self.throttle_label)
throttle_layout.addWidget(self.throttle_slider)
throttle_layout.addWidget(QLabel("Forward Max:"))
throttle_layout.addWidget(self.maxThrottle)
throttle_layout.addWidget(QLabel("Backward Max:"))
throttle_layout.addWidget(self.backwardMaxThrottle)
throttle_groupbox = QtGui.QGroupBox("Max Throttle Setting (30-99)")
throttle_groupbox.setLayout(throttle_layout)
示例7: SelectorView
# 需要导入模块: from PySide.QtGui import QSlider [as 别名]
# 或者: from PySide.QtGui.QSlider import setTickPosition [as 别名]
class SelectorView(QAbstractItemView):
"""View that sets selection by objects' relative size
"""
def __init__(self, parent=None):
# This view is not visible
super(SelectorView, self).__init__(None)
self._updating_selection = False
layout = QHBoxLayout()
layout.addWidget(QLabel("Select by size"))
self.slider = QSlider(Qt.Horizontal)
self.slider.setTickPosition(QSlider.TicksBothSides)
self.slider.setMinimum(-1)
self.slider.setMaximum(1)
self.slider.setTickInterval(1)
self.slider.setSingleStep(1)
self.slider.setEnabled(False)
self.slider.valueChanged.connect(self._slider_changed)
# Slider has stretch greater than zero to force left-alignment
layout.addWidget(self.slider, stretch=1)
self.widget = QWidget(parent)
self.widget.setLayout(layout)
def _update_slider(self, n):
"""Sets the slider range and enabled state
"""
self.slider.setEnabled(n > 0)
if n:
# Scale runs from -n to + n in steps of 1
self.slider.setMinimum(-n)
self.slider.setMaximum(n)
self.slider.setTickInterval(n)
self.slider.setSingleStep(1)
self.slider.setValue(0)
def _slider_changed(self, value):
"""QSlider.valueChanged slot
"""
debug_print('SelectorView._slider_changed', value)
if False and 0 == value:
# Do not alter selection if value is 0
pass
else:
# Order items by increasing / decreasing area and select the first n
model = self.model()
rows = xrange(model.rowCount())
def box_area(row):
rect = model.index(row, 0).data(RectRole)
return rect.width() * rect.height()
rows = sorted(rows, key=box_area, reverse=value < 0)
self._updating_selection = True
try:
update_selection_model(model, self.selectionModel(), rows[:abs(value)])
finally:
self._updating_selection = False
def single_step(self, larger):
"""Steps the slider up / down
"""
if self.slider.isEnabled():
action = QSlider.SliderSingleStepAdd if larger else QSlider.SliderSingleStepSub
self.slider.triggerAction(action)
def selectionChanged(self, selected, deselected):
"""QAbstractItemView virtual
"""
if not self._updating_selection:
self.slider.setValue(0)
def reset(self):
"""QAbstractItemView virtual
"""
debug_print('SelectorView.reset')
super(SelectorView, self).reset()
self._update_slider(self.model().rowCount())
def dataChanged(self, topLeft, bottomRight):
"""QAbstractItemView virtual
"""
debug_print('SelectorView.dataChanged')
self._update_slider(self.model().rowCount())
def rowsAboutToBeRemoved(self, parent, start, end):
"""QAbstractItemView slot
"""
debug_print('SelectorView.rowsAboutToBeRemoved')
self._update_slider(self.model().rowCount() - (end - start))