使用PYQT5简单制作动态仪表盘

还是使用旋转图片的简单方法,效果如图:

from sys import exit, argv

from PyQt5 import uic
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QTransform
from PyQt5.QtWidgets import QApplication


def setting():
    form0.jindu1.setPixmap(image_jindu.transformed(QTransform().rotate(form0.S1.value())))


def pointer():
    form0.zhizhen1.setPixmap(image_zhizhen.transformed(QTransform().rotate(form0.S2.value())))


if __name__ == '__main__':
    app = QApplication(argv)
    form0 = uic.loadUi('../UIS/仪表盘.ui')  # 生成并加载画面
    image_zhizhen = QPixmap("../UIS/指针.png")
    image_jindu = QPixmap("../UIS/进度.png")
    image_zhezhao = QPixmap("../UIS/遮罩.png")
    image_biaopan = QPixmap("../UIS/表盘.png")

    form0.biaopan1.setPixmap(image_biaopan)
    form0.jindu1.setPixmap(image_jindu)
    form0.zhezhao1.setPixmap(image_zhezhao)
    form0.zhizhen1.setPixmap(image_zhizhen)

    form0.biaopan1.setAlignment(Qt.AlignCenter)
    form0.jindu1.setAlignment(Qt.AlignCenter)
    form0.zhezhao1.setAlignment(Qt.AlignCenter)
    form0.zhizhen1.setAlignment(Qt.AlignCenter)

    form0.S1.valueChanged.connect(setting)
    form0.S2.valueChanged.connect(pointer)

    form0.show()

    exit(app.exec_())

 

你可能感兴趣的:(qt,数据库,开发语言)