先决条件
要将Qtitan组件用于Python,您需要:
- 安装Python3.6或者更高版本,点击此处获取:https://www.python.org
- MS Visual Studio或Qt-Creator
- 需要按照此处所述安装PySide2和shiboken2:https://wiki.qt.io/Qt_for_Python/GettingStarted
- 如果您需要为Qtitan组件重建Python binging,则必须安装shiboken2-generator软件包。 您可以通过以下链接找到wheels for shiboken2-generator:https://download.qt.io/official_releases/QtForPython/shiboken2-generator/
Step 1:为Python安装Qtitan组件
- 转到页面https://www.devmachines.com/download-for-qt.html
- 下载适合您所使用平台的安装程序,Python所需的组件在安装程序名称中带有后缀PySide2。
- 按照安装程序向导的建议进行安装。
- 安装过程完成后,您将在<QTITAN_INSTALL_PATH> site-packages / DevMachines文件夹中拥有python绑定。
此外,绑定将安装到安装了PySide2的Python第三方库文件夹中。例如:
c:PythonPython37-32Libsite-packagesPySide2 c:PythonPython37-32Libsite-packagesshiboken2c:PythonPython37-32Libsite-packagesDevMachines
要获取适合您环境的Python site-packages目录,请在site-packages程序中执行以下命令:
python -c "import site; print(site.getsitepackages())"
Step 2:将组件添加到Python文件(* .py)中
将Qtitan组件添加到Python文件中,所有组件都在DevMachines命名空间中。
from DevMachines.QtitanBase import WindowTitleBarfrom DevMachines.QtitanRibbon import AdobePhotoshopStyle, Office2016Style
Step 3:运行Python应用
运行您的Python应用,并确保没有任何错误和警告。
从源代码为Python构建Qtitan组件绑定
本部分描述如何从源代码为Python构建Qtitan组件绑定。
Windows Visual Studio
对于Visual Studio,您必须使用Visual Studio Toolkit 2015来构建绑定。 如果您将使用2017 Toolkit,则shiboken2-generator会出现错误。
Open the bat shell. "Windows logo key" + R, cmd.exe Set current directory to the <QTITAN_INSTALL_PATH>. C:/>dir <QTITAN_INSTALL_PATH> vcvars32_2015.bat qmake.exe -r CONFIG+=python -platform win32-msvcnmake release
构建过程完成后,您将在<QTITAN_INSTALL_PATH> site-packages / DevMachines文件夹中拥有一个新的绑定库。
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!