您的位置:首页 > 编程语言 > Qt开发

PyQt快速编程小案例4

2017-03-14 03:38 267 查看
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/3/12 20:10
"""
编写值变化型槽代码会判断检测的目标值和当前值是否存在差异
如果相同就什么都不做,所以不会进入死循环
"""
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
dial = QDial()
dial.setNotchesVisible(True)
dial.setRange(0, 7)
spinbox = QSpinBox()
spinbox.setRange(0, 7)

layout = QHBoxLayout()
layout.addWidget(dial)
layout.addWidget(spinbox)
self.setLayout(layout)
self.connect(dial, SIGNAL("valueChanged(int)"), spinbox.setValue),
self.connect(spinbox, SIGNAL("valueChanged(int)"), dial.setValue)
self.setWindowTitle("Signals and Slots")

if __name__ == '__main__':
app = QApplication(sys.argv)
form = Form()
form.show()
app.exec_()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: