Code Monkey home page Code Monkey logo

pyside2's Introduction

PySide2 入门教程

Qt是一种强大的图形用户界面构造工具,如今它对于Python也有很好的接口支持, 分别是PyQt和PySide。PyQt采用需购买版权的商业及GPL许可,而PySide采用无需 购买版权的LGPL许可。PySide与PyQt有非常相容的API,因此无需版权的PySide更 适合广大Python爱好者的学习。PySide2支持Qt5框架,兼容Python2.7以上版本及 Python3.5以上版本。本教程以PySide2为例,讲述如何从显示一个简单的 hello world窗口到设置井然有序窗口布局。介于作者时间有限,此教程只讲述如何 入门并高效使用Qt,至于每个控件如何使用,各位爱好者自己学习吧,网络上各种资 源一大把。俗话说,师傅领进门,修行靠个人,我的每个教程都有详细的代码供大家 参考,有问题可以直接在github上提出,共同进步!

致谢

截至2021年9月,本项目在github有上百star,在gitee也有上百star,感谢各位码友的支持!

pyside2's People

Contributors

se7enxf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyside2's Issues

Lession5 can't display .jpg images.

I tested the code of lession 5 with several .png files,it worked well.But it just can't display any .jpg file and there are no error messages. (My env: Win10,Pyside2 5.15.2.1)
A jpg image and a png image I use are attached below.
dog2
fish

关于高分屏幕缩放的问题

因为最近在学习Pyside2的使用,我使用的是4k屏幕,笔记本(缩放250%),如果Qtdesigner直接绘制出来的图预览大小是缩放后的,大小是正常的,但是生成代码直接运行后,就会变得非常小,在网上搜索到的解决方案是:

if __name__ == '__main__':
    # from Pyside2 import QtCore
    # 设置允许高分辨率缩放
    QtCore.QCoreApplication.setAttribute(QtCore.Qt.ApplicationAttribute.AA_EnableHighDpiScaling)
    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()
    window.window_init()
    window.show()
    sys.exit(app.exec_())

需要在创建app之前加入上面的语句

pyside2-uic生成py文件不是utf-8编码导致保存问题

发现了个bug,可能版本不同了吧。在Lesson02中使用以下命令生成的ui_mainwindow.py文件是用utf-16编码,导致执行main.py的时候报错。

pyside2-uic [你保存的文件名].ui > ui_mainwindow.py

搜索后发现,将> 改成-o即可使用utf-8编码

Can not play video with QMediaPlayer

使用 QMediaPlayer 播放视频失败

本打算在第九课讲这个的,但是一直失败,就只能拿之前写的浏览器代码来充数了。。。
我是用的代码根据Qt官网改写的:

# 这是一个空的widget
widget = QtWidgets.QWidget()
widget_layout = QtWidgets.QVBoxLayout()
videoWidget = QVideoWidget()
widget_layout.addWidget(videoWidget)
widget.setLayout(widget_layout)

player = QMediaPlayer()
player.setVideoOutput(videoWidget)
player.setMedia(QUrl.fromLocalFile("example.mp4"))
player.play()

代码开头的widget是放置在主窗口内的,运行程序没有报错也没声音和图像。So can you help help me?

Markdown语法的规范问题

Markdown的每个符号, 都是有其语义的(就像HTML标签一样)

另外,不同的部分在文章中的顺序, 也可以规范一下。 例如参考文献一般在后面。

把第一篇文章修改了一下, 大概长这样:

环境配置与入门

概要

这里可以写一下, 这篇文章主要的目的是什么

软件开发环境

  • Python3.6
  • PySide2

操作系统相关环境

安装PySide2

关于Python的安装请自行学习,这里不再累述。
安装PySide2的PyPI,命令行:

pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.11/
latest/ pyside2 --trusted-host download.qt.io*  

bash指令可以放在code代码块里面。

下集预告:Hello world!

万程开头helloworld!作者编写的的这个helloworld.py是根据官网教程改编的,里面也写了详细的注释。
此方法,只使用编写代码来实现Qt窗口。当我们设计复杂且美观的窗口时,只使用代码来编写必定是非常繁琐的。
因此,在下一讲中,会介绍一种结合QtDesigner的用户界面绘制方法,能让我们更高效的实现QtUI。
当你配置好环境,可以直接运行helloworld.py,如果成功运行并显示如下窗口,那么恭喜你入坑!
hello_world

参考文档

PySide官方文档 Qt for Python

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.