当前位置: 首页>>代码示例>>Python>>正文


Python QDial.value方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QDial.value方法的典型用法代码示例。如果您正苦于以下问题:Python QDial.value方法的具体用法?Python QDial.value怎么用?Python QDial.value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QDial的用法示例。


在下文中一共展示了QDial.value方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LightChannel

# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import value [as 别名]
class LightChannel(QWidget):
	changed = pyqtSignal(object)
	def __init__(self, parent, update_callback):
		QWidget.__init__(self, parent)
		self.layout = QGridLayout()
		self.setLayout(self.layout)
		self.update_callback = update_callback


		self.light_value = QSlider(self)
		self.hue_value = QDial(self)
		self.saturation_value = QDial(self)
		self.monitor = Monitor(self)

		self.layout.addWidget(QLabel('Hue'), 0, 0, Qt.AlignHCenter)
		self.layout.addWidget(self.hue_value, 1, 0, Qt.AlignHCenter)
		self.layout.addWidget(QLabel('Saturation'), 2, 0, Qt.AlignHCenter)
		self.layout.addWidget(self.saturation_value, 3, 0, Qt.AlignHCenter)
		self.layout.addWidget(self.monitor, 4, 0, Qt.AlignHCenter)
		self.layout.addWidget(QLabel('Intensity'), 5, 0, Qt.AlignHCenter)
		self.layout.addWidget(self.light_value, 6, 0, Qt.AlignHCenter)

		self.update()

		self.hue_value.valueChanged.connect(self.update)
		self.saturation_value.valueChanged.connect(self.update)
		self.light_value.valueChanged.connect(self.update)


	def get_rgb(self):
		saturation = self.saturation_value.value()/99.0
		light = self.light_value.value()/99.0
		hue = self.hue_value.value()/99.0

		return colorsys.hsv_to_rgb(hue, saturation, light)

	def update(self):
		r, g, b = self.get_rgb()
		self.monitor.setColor(r, g, b)
		self.update_callback.setColor(r, g, b)
		self.changed.emit(self)
开发者ID:ledalert,项目名称:led-nekrosfilm-sw,代码行数:43,代码来源:ljusbord.py

示例2: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QDial [as 别名]
# 或者: from PyQt5.QtWidgets.QDial import value [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()

#.........这里部分代码省略.........
开发者ID:juancarlospaco,项目名称:pyvoicechanger,代码行数:103,代码来源:pyvoicechanger.py


注:本文中的PyQt5.QtWidgets.QDial.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。