#计数器控件QSpinBox
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
class QSpinBoxDemo(QWidget):
def __init__(self):
super(QSpinBoxDemo,self).__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('QSpinBox演示')
self.resize(300,200)
layout = QVBoxLayout()
self.label = QLabel('当前值: 2')
self.label.setAlignment(Qt.AlignCenter)
layout.addWidget(self.label)
self.spinb = QSpinBox()
self.spinb.setValue(2)
layout.addWidget(self.spinb)
self.spinb.valueChanged.connect(self.valuechange)
self.setLayout(layout)
def valuechange(self):
self.label.setText('当前值:'+str(self.spinb.value()))
if __name__ == '__main__':
app =QApplication(sys.argv)
main = QSpinBoxDemo()
main.show()
app.exit(app.exec_())
PyQT5计数器控件
最新推荐文章于 2024-05-17 22:41:47 发布