pyside2之‘Hello world‘

先安装pyside

yay -S pyside2   

windows可以

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyside2

新建一个项目测试
在这里插入图片描述在这里插入图片描述

# This Python file uses the following encoding: utf-8
import sys
from PySide2.QtWidgets import QApplication, QWidget,QMainWindow,QPushButton,QPlainTextEdit,QMessageBox


def handleCalc():
    info = textEdit.toPlainText()
    QMessageBox.about(window, '标题','hello world')


if __name__ == "__main__":
    app = QApplication([])
    window = QMainWindow()
    window.resize(600,400)
    window.move(300,300)
    window.setWindowTitle("hello Window")

    textEdit = QPlainTextEdit(window)
    textEdit.setPlaceholderText("hello textEdit")
    textEdit.move(10,25)
    textEdit.resize(300,350)

    button = QPushButton("弹出", window)
    button.move(380,80)
    button.clicked.connect(handleCalc)

    window.show()
    sys.exit(app.exec_())

猜你喜欢

转载自blog.csdn.net/qq_33831360/article/details/107558381