zoukankan      html  css  js  c++  java
  • Qt for Python 怎样搭建开发环境

    方法/步骤

    按住win+R键,输入cmd打开命令行工具。在命令行中输入python -V 后回车,查看自己电脑中python版本是否符合安装要求。

    怎样搭建Qt for Python开发环境

    在命令行中输入 pip install PySide2 从pip包管理软件进行安装下载。成功安装后,会有如图片所示 "successfully installed PySide2-5.12.0" 出现。

    怎样搭建Qt for Python开发环境
    怎样搭建Qt for Python开发环境

    在搜索栏输入IDLE,打开python 自带的 IDLE 工具。新建一个脚本文件并保存为helloworld.py.

    怎样搭建Qt for Python开发环境
     1 在代码输入栏写上如下代码:
     2 
     3 import sys
     4 
     5 import random
     6 
     7 from PySide2 import QtCore, QtWidgets, QtGui
     8 
     9 class MyWidget(QtWidgets.QWidget):
    10 
    11     def __init__(self):
    12 
    13         super().__init__()
    14 
    15         self.text = QtWidgets.QLabel("Hello World")
    16 
    17         self.text.setAlignment(QtCore.Qt.AlignCenter)
    18 
    19         self.layout = QtWidgets.QVBoxLayout()
    20 
    21         self.layout.addWidget(self.text)
    22 
    23         self.setLayout(self.layout)
    24 
    25 if __name__ == "__main__":
    26 
    27     app = QtWidgets.QApplication([])
    28 
    29     widget = MyWidget()
    30 
    31     widget.resize(400, 300)
    32 
    33     widget.show()
    34 
    35     sys.exit(app.exec_())
    怎样搭建Qt for Python开发环境

    点击 Run -> Run Module 对程序进行运行,会出现一个带有Helloword字样的界面。

    怎样搭建Qt for Python开发环境
    怎样搭建Qt for Python开发环境
  • 相关阅读:
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    POJ 1840 Eqs(乱搞)题解
    UVALive 6955 Finding Lines(随机化优化)题解
    CodeForces 828E DNA Evolution(树状数组)题解
    UVA 11019 Matrix Matcher(二维hash + 尺取)题解
  • 原文地址:https://www.cnblogs.com/ybqjymy/p/14077716.html
Copyright © 2011-2022 走看看