标签:demo dem span 技术 image max 调整 init info
样式:
1 import sys 2 from PyQt5.QtGui import QFont 3 from PyQt5.QtWidgets import QApplication, QWidget, QDial, QLabel, QHBoxLayout 4 5 6 class Demo(QWidget): 7 def __init__(self): 8 super(Demo, self).__init__() 9 self.setWindowTitle(‘旋转按钮‘) 10 11 self.dial = QDial(self) #实例化旋转按钮 12 self.dial.setFixedSize(100, 100) # 固定旋钮大小,否则会随窗口的变化而发生变化 13 self.dial.setRange(0, 100) #设置表盘数值范围,当然也可以使用setMinimum()和setMaximum()方法 14 self.dial.setNotchesVisible(True) # 是否显示刻度,刻度会根据我们设置的数值自动调整 15 self.dial.valueChanged.connect(self.on_change_func) # 当数值发生变化时发出信号 16 17 self.label = QLabel(‘0‘, self) 18 self.label.setFont(QFont(‘Arial Black‘, 20)) 19 20 self.h_layout = QHBoxLayout() 21 self.h_layout.addWidget(self.dial) 22 self.h_layout.addWidget(self.label) 23 24 self.setLayout(self.h_layout) 25 26 def on_change_func(self): 27 self.label.setText(str(self.dial.value())) 28 29 30 if __name__ == ‘__main__‘: 31 app = QApplication(sys.argv) 32 demo = Demo() 33 demo.show() 34 sys.exit(app.exec_())
标签:demo dem span 技术 image max 调整 init info
原文地址:https://www.cnblogs.com/liming19680104/p/10360796.html