我无法使用Pyinstaller生成exe文件。我最大的问题应该是“包括qml文件”。我尝试了很多,但仍然失败。希望有人能告诉我应该如何编写spec文件以包含QML。Pyinstaller:如何为简单的Pyside + QML应用程序包含QML文件?
通常,我想要的是从我的Pyside + QML应用程序创建Windows Exe。但是如何?
main.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import QDeclarativeView
# Create Qt application and the QDeclarative view
app = QApplication(sys.argv)
view = QDeclarativeView()
# Create an URL to the QML file
url = QUrl('view.qml')
# Set the QML file and show
view.setSource(url)
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.show()
# Enter Qt main loop
sys.exit(app.exec_())
view.qml
import QtQuick 1.0
Rectangle {
width: 200
height: 200
color: "red"
Text {
text: "Hello World"
anchors.centerIn: parent
}
}
包含'qml'文件可以通过PyInstaller完成,但是'QtDeclarative'不支持](http://www.pyinstaller.org/ticket/374)。 – Avaris
我在spec文件中通过a.datas包含了qml文件。可能它还没有被支持。那么cx_freeze是否可以做到这一点? –
也许...我从来没有用过'cx_freeze',所以我不知道。 – Avaris