ubuntu 16.04 LTS - PyQt5

ubuntu 16.04 LTS - PyQt5

https://pypi.org/project/PyQt5/

Python bindings for the Qt cross platform UI and application toolkit.
用于 Qt 跨平台 UI 和应用程序工具包的 Python 封装。

Qt is set of cross-platform C++ libraries that implement high-level APIs for accessing many aspects of modern desktop and mobile systems. These include location and positioning services, multimedia, NFC and Bluetooth connectivity, a Chromium based web browser, as well as traditional UI development.
Qt 是一套跨平台的 C++ 库,它们实现了高级 API,可以访问现代桌面和移动系统的许多方面。这些包括定位和定位服务、多媒体、NFC 和蓝牙连接,基于 Chromium 的 Web 浏览器,以及传统的 UI 开发。

PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.
PyQt5 是 Qt v5 的一套全面的 Python 封装。它实现为超过 35 个扩展模块,并使 Python 能够在所有支持的平台 (包括 iOS 和 Android) 上用作 C++ 的替代应用程序开发语言。

PyQt5 may also be embedded in C++ based applications to allow users of those applications to configure or enhance the functionality of those applications.
PyQt5 也可以嵌入到基于 C++ 的应用程序中,以允许这些应用程序的用户配置或增强这些应用程序的功能。

PyQt5 is released under the GPL v3 license and under a commercial license that allows for the development of proprietary applications.
PyQt5 是根据 GPL v3 许可证和商业许可证发布的,该许可证允许开发专有应用程序。

1. PyQt5 Reference Guide

https://www.riverbankcomputing.com/static/Docs/PyQt5/

2. Installing PyQt5

pip3 install PyQt5
pip3 install PyQt5==5.10
pip3 install PyQt5==5.12

3. Installing from Wheels

Wheels are the standard Python packaging format for pure Python or binary extension modules such as PyQt5. Only Python v3.5 and later are supported. Wheels are provide for 32- and 64-bit Windows, 64-bit macOS and 64-bit Linux. These correspond with the platforms for which The Qt Company provide binary installers.
wheels 是纯 Python 或二进制扩展模块 (PyQt5) 的标准 Python 打包格式。仅支持 Python v3.5 及更高版本。wheels 提供 32 位和 64 位 Windows,64 位 macOS 和 64 位 Linux。这些对应于 Qt 公司为其提供二进制安装程序的平台。

Wheels are installed using the pip3 program that is included with current versions of Python.
使用当前版本的 Python 附带的 pip3 程序安装 wheels。

3.1 Installing the GPL Version

To install the wheel for the GPL version of PyQt5, run:

pip3 install PyQt5

This will install the wheel for your platform and your version of Python (assuming both are supported). The wheel will be automatically downloaded from the Python Package Index.
这将为您的平台和您的 Python 版本安装 wheel (假设两者都受支持)。该 wheel 将自动从 Python 包索引下载。

If you get an error message saying that no downloads could be found that satisfy the requirement then you are probably using an unsupported version of Python.
如果您收到一条错误消息,指出无法找到满足该要求的下载,那么您可能正在使用不受支持的 Python 版本。

The PyQt5 wheel includes the necessary parts of the LGPL version of Qt. There is no need to install Qt yourself.
PyQt5 wheel 包含 LGPL 版 Qt 的必要部分。没有必要自己安装 Qt。

SIP is packaged as a separate wheel which will be downloaded and installed automatically.
SIP 打包为单独的 wheel,将自动下载和安装。

To uninstall the GPL version, run:
要卸载 GPL 版本,请运行:

pip3 uninstall PyQt5

sudo pip3 install PyQt5==5.12

strong@foreverstrong:~$ sudo pip3 install PyQt5==5.12
[sudo] password for strong: 
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/strong/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting PyQt5==5.12
  Downloading https://files.pythonhosted.org/packages/01/8c/eeff014306fcdbb8afda0fe603d1b458dddf2be0ca10d561b0015e439357/PyQt5-5.12-5.12.1_a-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl (61.1MB)
    100% |████████████████████████████████| 61.1MB 20kB/s 
Collecting PyQt5_sip<4.20,>=4.19.14 (from PyQt5==5.12)
  Downloading https://files.pythonhosted.org/packages/cd/0f/03dae28b4a1df61f770a299d2402021844602ece43a4ef7cd5c49495f5e1/PyQt5_sip-4.19.15-cp35-cp35m-manylinux1_x86_64.whl (67kB)
    100% |████████████████████████████████| 71kB 111kB/s 
Installing collected packages: PyQt5-sip, PyQt5
Successfully installed PyQt5-5.12 PyQt5-sip-4.19.15
You are using pip version 8.1.1, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$

4. Hello World Example

The below code shows a small window on the screen.

#! /usr/bin/python3
# Character Encoding: UTF-8
#
# Here we provide the necessary imports.
# The basic GUI widgets are located in QtWidgets module.
import sys
from PyQt5.QtWidgets import QApplication, QWidget

# Every PyQt5 application must create an application object.
# The application object is located in the QtWidgets module.
app = QApplication(sys.argv)

# The QWidget widget is the base class of all user interface objects in PyQt5.
# We provide the default constructor for QWidget. The default constructor has no parent.
# A widget with no parent is called a window.
root = QWidget()

root.resize(320, 240)  # The resize() method resizes the widget.
root.setWindowTitle("Hello, World!")  # Here we set the title for our window.
root.show()  # The show() method displays the widget on the screen.

sys.exit(app.exec_())  # Finally, we enter the mainloop of the application.

/usr/bin/python3.5 /home/strong/pyqt5_workspace/pyqt5_sample.py

在这里插入图片描述

References

PyQt5 Reference Guide
https://www.riverbankcomputing.com/static/Docs/PyQt5/index.html

PyQt5 tutorial
http://zetcode.com/gui/pyqt5/

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读