本文整理汇总了Python中PyQt5.QtWidgets.QDial.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python QDial.setValue方法的具体用法?Python QDial.setValue怎么用?Python QDial.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QDial
的用法示例。
在下文中一共展示了QDial.setValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createBottomRightGroupBox
# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import setValue [as 别名]
def createBottomRightGroupBox(self):
self.bottomRightGroupBox = QGroupBox("Group 3")
self.bottomRightGroupBox.setCheckable(True)
self.bottomRightGroupBox.setChecked(True)
lineEdit = QLineEdit('s3cRe7')
lineEdit.setEchoMode(QLineEdit.Password)
spinBox = QSpinBox(self.bottomRightGroupBox)
spinBox.setValue(50)
dateTimeEdit = QDateTimeEdit(self.bottomRightGroupBox)
dateTimeEdit.setDateTime(QDateTime.currentDateTime())
slider = QSlider(Qt.Horizontal, self.bottomRightGroupBox)
slider.setValue(40)
scrollBar = QScrollBar(Qt.Horizontal, self.bottomRightGroupBox)
scrollBar.setValue(60)
dial = QDial(self.bottomRightGroupBox)
dial.setValue(30)
dial.setNotchesVisible(True)
layout = QGridLayout()
layout.addWidget(lineEdit, 0, 0, 1, 2)
layout.addWidget(spinBox, 1, 0, 1, 2)
layout.addWidget(dateTimeEdit, 2, 0, 1, 2)
layout.addWidget(slider, 3, 0)
layout.addWidget(scrollBar, 4, 0)
layout.addWidget(dial, 3, 1, 2, 1)
layout.setRowStretch(5, 1)
self.bottomRightGroupBox.setLayout(layout)
示例2: setValue
# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import setValue [as 别名]
def setValue(self, value):
if self.fRealValue == value:
return
self.fRealValue = value
normValue = float(value - self.fMinimum) / float(self.fMaximum - self.fMinimum)
QDial.setValue(self, int(normValue * 10000))
示例3: __init__
# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import setValue [as 别名]
def __init__(self, parent, index=0):
QDial.__init__(self, parent)
self.fMinimum = 0.0
self.fMaximum = 1.0
self.fRealValue = 0.0
self.fIsHovered = False
self.fHoverStep = self.HOVER_MIN
self.fIndex = index
self.fPixmap = QPixmap(":/bitmaps/dial_01d.png")
self.fPixmapNum = "01"
if self.fPixmap.width() > self.fPixmap.height():
self.fPixmapOrientation = self.HORIZONTAL
else:
self.fPixmapOrientation = self.VERTICAL
self.fLabel = ""
self.fLabelPos = QPointF(0.0, 0.0)
self.fLabelFont = QFont(self.font())
self.fLabelFont.setPointSize(6)
self.fLabelWidth = 0
self.fLabelHeight = 0
if self.palette().window().color().lightness() > 100:
# Light background
c = self.palette().dark().color()
self.fLabelGradientColor1 = c
self.fLabelGradientColor2 = QColor(c.red(), c.green(), c.blue(), 0)
self.fLabelGradientColorT = [self.palette().buttonText().color(), self.palette().mid().color()]
else:
# Dark background
self.fLabelGradientColor1 = QColor(0, 0, 0, 255)
self.fLabelGradientColor2 = QColor(0, 0, 0, 0)
self.fLabelGradientColorT = [Qt.white, Qt.darkGray]
self.fLabelGradient = QLinearGradient(0, 0, 0, 1)
self.fLabelGradient.setColorAt(0.0, self.fLabelGradientColor1)
self.fLabelGradient.setColorAt(0.6, self.fLabelGradientColor1)
self.fLabelGradient.setColorAt(1.0, self.fLabelGradientColor2)
self.fLabelGradientRect = QRectF(0.0, 0.0, 0.0, 0.0)
self.fCustomPaintMode = self.CUSTOM_PAINT_MODE_NULL
self.fCustomPaintColor = QColor(0xff, 0xff, 0xff)
self.updateSizes()
# Fake internal value, 10'000 precision
QDial.setMinimum(self, 0)
QDial.setMaximum(self, 10000)
QDial.setValue(self, 0)
self.valueChanged.connect(self.slot_valueChanged)
示例4: setValue
# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import setValue [as 别名]
def setValue(self, value, emitSignal=False):
if self.fRealValue == value:
return
if value <= self.fMinimum:
qtValue = 0
self.fRealValue = self.fMinimum
elif value >= self.fMaximum:
qtValue = self.fPrecision
self.fRealValue = self.fMaximum
else:
qtValue = round(float(value - self.fMinimum) / float(self.fMaximum - self.fMinimum) * self.fPrecision)
self.fRealValue = value
# Block change signal, we'll handle it ourselves
self.blockSignals(True)
QDial.setValue(self, qtValue)
self.blockSignals(False)
if emitSignal:
self.realValueChanged.emit(self.fRealValue)
示例5: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import setValue [as 别名]
class MainWindow(QMainWindow):
"""Voice Changer main window."""
def __init__(self, parent=None):
super(MainWindow, self).__init__()
self.statusBar().showMessage("Move Dial to Deform Microphone Voice !.")
self.setWindowTitle(__doc__)
self.setMinimumSize(240, 240)
self.setMaximumSize(480, 480)
self.resize(self.minimumSize())
self.setWindowIcon(QIcon.fromTheme("audio-input-microphone"))
self.tray = QSystemTrayIcon(self)
self.center()
QShortcut("Ctrl+q", self, activated=lambda: self.close())
self.menuBar().addMenu("&File").addAction("Quit", lambda: exit())
self.menuBar().addMenu("Sound").addAction(
"STOP !", lambda: call('killall rec', shell=True))
windowMenu = self.menuBar().addMenu("&Window")
windowMenu.addAction("Hide", lambda: self.hide())
windowMenu.addAction("Minimize", lambda: self.showMinimized())
windowMenu.addAction("Maximize", lambda: self.showMaximized())
windowMenu.addAction("Restore", lambda: self.showNormal())
windowMenu.addAction("FullScreen", lambda: self.showFullScreen())
windowMenu.addAction("Center", lambda: self.center())
windowMenu.addAction("Top-Left", lambda: self.move(0, 0))
windowMenu.addAction("To Mouse", lambda: self.move_to_mouse_position())
# widgets
group0 = QGroupBox("Voice Deformation")
self.setCentralWidget(group0)
self.process = QProcess(self)
self.process.error.connect(
lambda: self.statusBar().showMessage("Info: Process Killed", 5000))
self.control = QDial()
self.control.setRange(-10, 20)
self.control.setSingleStep(5)
self.control.setValue(0)
self.control.setCursor(QCursor(Qt.OpenHandCursor))
self.control.sliderPressed.connect(
lambda: self.control.setCursor(QCursor(Qt.ClosedHandCursor)))
self.control.sliderReleased.connect(
lambda: self.control.setCursor(QCursor(Qt.OpenHandCursor)))
self.control.valueChanged.connect(
lambda: self.control.setToolTip(f"<b>{self.control.value()}"))
self.control.valueChanged.connect(
lambda: self.statusBar().showMessage(
f"Voice deformation: {self.control.value()}", 5000))
self.control.valueChanged.connect(self.run)
self.control.valueChanged.connect(lambda: self.process.kill())
# Graphic effect
self.glow = QGraphicsDropShadowEffect(self)
self.glow.setOffset(0)
self.glow.setBlurRadius(99)
self.glow.setColor(QColor(99, 255, 255))
self.control.setGraphicsEffect(self.glow)
self.glow.setEnabled(False)
# Timer to start
self.slider_timer = QTimer(self)
self.slider_timer.setSingleShot(True)
self.slider_timer.timeout.connect(self.on_slider_timer_timeout)
# an icon and set focus
QLabel(self.control).setPixmap(
QIcon.fromTheme("audio-input-microphone").pixmap(32))
self.control.setFocus()
QVBoxLayout(group0).addWidget(self.control)
self.menu = QMenu(__doc__)
self.menu.addAction(__doc__).setDisabled(True)
self.menu.setIcon(self.windowIcon())
self.menu.addSeparator()
self.menu.addAction(
"Show / Hide",
lambda: self.hide() if self.isVisible() else self.showNormal())
self.menu.addAction("STOP !", lambda: call('killall rec', shell=True))
self.menu.addSeparator()
self.menu.addAction("Quit", lambda: exit())
self.tray.setContextMenu(self.menu)
self.make_trayicon()
def run(self):
"""Run/Stop the QTimer."""
if self.slider_timer.isActive():
self.slider_timer.stop()
self.glow.setEnabled(True)
call('killall rec ; killall play', shell=True)
self.slider_timer.start(3000)
def on_slider_timer_timeout(self):
"""Run subprocess to deform voice."""
self.glow.setEnabled(False)
value = int(self.control.value()) * 100
command = f'play -q -V0 "|rec -q -V0 -n -d -R riaa bend pitch {value} "'
print(f"Voice Deformation Value: {value}")
print(f"Voice Deformation Command: {command}")
self.process.start(command)
if self.isVisible():
self.statusBar().showMessage("Minimizing to System TrayIcon", 3000)
print("Minimizing Main Window to System TrayIcon now...")
sleep(3)
self.hide()
#.........这里部分代码省略.........
示例6: printValue
# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import setValue [as 别名]
from PyQt5.QtWidgets import QApplication, QDial
def printValue(value):
print(value, dial.value())
app = QApplication(sys.argv)
dial = QDial()
#dial.setMinimum(-15)
#dial.setMaximum(15)
dial.setRange(-15, 15)
dial.setNotchesVisible(True)
dial.setValue(5) # Initial value
dial.valueChanged.connect(printValue)
dial.show()
# The mainloop of the application. The event handling starts from this point.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
exit_code = app.exec_()
# The sys.exit() method ensures a clean exit.
# The environment will be informed, how the application ended.
sys.exit(exit_code)