PySide6-FluentUI-QML 使用记录 python + pyside6 + qml

PySide6-FluentUI-QML 是一个ui库,官网地址为 https://github.com/zhuzichu520/FluentUI

作用:美化qml文件,快速构建项目

简单使用

1.pip install pyside6
安装pyside6
2.pip install PySide6-FluentUI-QML
安装PySide6-FluentUI-QML

3.加载fluentui

## main.py


import sys
import FluentUI   # 导入FluentUI
from PySide6.QtCore import *
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine

class MyWindow(QObject):
    def __init__(self):
        super().__init__()
        self.engine = QQmlApplicationEngine()
        FluentUI.init(self.engine)   # 加载FluentUI
        qml = "main.qml"
        self.engine.load(QUrl.fromLocalFile(qml))

if __name__ == "__main__":
    app = QGuiApplication().instance()
    if app is None:
        app = QGuiApplication(sys.argv)
    window = MyWindow()
    result = app.exec()
    sys.exit(result)

4.使用

## main.qml


import QtQuick
import FluentUI

FluWindow {
    width: 640
    height: 480
    visible: true
    title: "fluentui"
    FluButton {
        id: homeButton
        text: "按钮"
        anchors.centerIn:parent
    }
}

详细使用可参阅 https://github.com/zhuzichu520/FluentUI/releases 下载exe文件查看使用效果.

或下载源码 https://github.com/zhuzichu520/FluentUI 后,参照task.json文件内的提示执行
python ./Scripts/qrc2py.py ./example/resource/example.qrc ./example/resource/example_rc.py 后,
在执行example/main.py也可以运行。
使用可参照example/resource/qml内的qml文件使用

小白记录,如有问题请留言

posted @   嘚惹  阅读(294)  评论(2编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示