Qt6 QML Book/Qt for Python/安装过程

Installing

安装过程

Qt for Python is available through PyPA using pip under the name pyside6. In the example below we setup a venv environment in which we will install the latest version of Qt for Python:

PyPA使用名为pyside6的pip提供了用于Python的Qt。在下面的示例中,我们设置了一个venv环境,在其中我们将安装最新版本的Qt for Python:

mkdir qt-for-python
cd qt-for-python
python3 -m venv .
source bin/activate
(qt-for-python) $ python --version
Python 3.9.6

When the environment is setup, we continue to install pyside6 using pip:

环境设置完成后,我们将继续使用pip安装pyside6:

(qt-for-python) $ pip install pyside6
Collecting pyside6
Downloading [ ... ] (60.7 MB)
Collecting shiboken6==6.1.2
Downloading [ ... ] (1.0 MB)
Installing collected packages: shiboken6, pyside6
Successfully installed pyside6-6.1.2 shiboken6-6.1.2

After the installation, we can test it by running a Hello World example from the interactive Python prompt:

安装完成后,我们可以通过在交互式Python提示符下运行Hello World示例来测试它:

(qt-for-python) $ python
Python 3.9.6 (default, Jun 28 2021, 06:20:32) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PySide6 import QtWidgets
>>> import sys
>>> app = QtWidgets.QApplication(sys.argv)
>>> widget = QtWidgets.QLabel("Hello World!")
>>> widget.show()
>>> app.exec()
0
>>>

The example results in a window such as the one shown below. To end the program, close the window.

该示例将生成一个如下所示的窗口。要结束程序,请关闭窗口。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值