标签:class exec elf == prope exe port main init
1 import sys 2 from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout,QLabel 3 from PyQt5.QtGui import QColor 4 from PyQt5.QtCore import pyqtProperty,Qt 5 6 7 class Demo(QWidget): 8 def __init__(self): 9 super(Demo, self).__init__() 10 self.c=QColor(Qt.red) 11 12 @pyqtProperty(QColor) #获取属性,注意要传入属性的类型 13 def color(self): 14 return self.c 15 16 @color.setter #设置属性 17 def color(self,value): 18 self.c=value 19 20 21 if __name__ == ‘__main__‘: 22 app = QApplication(sys.argv) 23 demo = Demo() 24 25 print(demo.color) 26 demo.color=QColor(90,90,90) 27 print(demo.color) 28 29 demo.show() 30 sys.exit(app.exec_())
标签:class exec elf == prope exe port main init
原文地址:https://www.cnblogs.com/liming19680104/p/10425347.html