[Python] 如何在windows10下搭建pyqt6环境

关于pyqt6

Qt库是最强大的GUI库之一。PyQt6是由Riverbank Computing公司开发的。

PyQt6 是基于 Python 的一系列模块。它是一个多平台的工具包,可以在包括Unix、Windows和Mac OS在内的大部分主要操作系统上运行。PyQt6 有两个许可证,开发人员可以在 GPL 和商业许可之间进行选择。

PyQt6的官网:http://www.riverbankcomputing.co.uk/news。

Reference Guide — PyQt Documentation v6.6.0 (riverbankcomputing.com)

Introduction

This is the reference guide for PyQt6 v6.6. PyQt6 is a set of Python bindings for v6 of the Qt application framework from The Qt Company.

Qt is a set of C++ libraries and development tools that includes platform independent abstractions for graphical user interfaces, networking, threads, regular expressions, SQL databases, SVG, OpenGL, XML, user and application settings, positioning and location services, short range communications (NFC and Bluetooth), web browsing, 3D animation, charts, 3D data visualisation and interfacing with app stores.

PyQt6 comprises PyQt6 itself and a number of add-ons that correspond to Qt’s additional libraries. At the moment these are PyQt6-3D and PyQt6-NetworkAuth. Each is provided as a source distribution (sdist) and binary wheels for Windows, Linux and macOS.

PyQt6 supports the Windows, Linux, Android, macOS and iOS platforms and requires Python v3.6.1 or later.

The homepage for PyQt6 is Riverbank Computing | Introduction. Here you will always find the latest stable version and current development snapshots.

通过conda创建虚拟环境

conda create -y -n yolo_tools_310 python=3.10

如何安装和使用conda,可以阅读:[Python] conda、anaconda、miniconda的关系,miniconda安装,conda命令使用

激活虚拟环境

conda activate yolo_tools_310

通过pip来安装pyqt6

pip install pyqt6

验证pyqt6安装成功

第一个pyqt6应用程序

from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget
import sys


def center_window(window:QWidget):
    q_rect = window.frameGeometry()  # 得到一个指定主窗口几何形状的矩形
    cp = window.screen().availableGeometry().center()  # 计算出显示器的分辨率,通过分辨率得出中心点
    q_rect.moveCenter(cp)  # 设置为屏幕的中心,矩形大小不变
    window.move(q_rect.topLeft())


app = QApplication(sys.argv)
window = QMainWindow()
window.setWindowTitle("Yolo工具箱")
window.setGeometry(0, 0, 800, 600)
window.statusBar().showMessage("欢迎来到Yolo工具箱")
window.menuBar().addMenu("训练管理")
center_window(window)
window.showMaximized()

sys.exit(app.exec())

  • 26
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老狼IT工作室

你的鼓励将是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值