1 the environment
- Python3.6
- PyCharm community edition
- Anaconda
- pyside6.1.0
2 Create a virtual environment
The installation pyside6
pip install pyside6
Copy the code
4 The first interface
"" first test page @author xindaqi @date 2021-05-22 22:33 ""
import sys
import random
from PySide6 import QtCore, QtWidgets, QtGui
class FirstGui(QtWidgets.QWidget) :
def __init__(self) :
super().__init__()
self.hello = ["Python"."Java"."C++"]
self.button = QtWidgets.QPushButton("Dot me, dot me, dot me.")
self.text = QtWidgets.QLabel("First page". alignment=QtCore.Qt.AlignCenter) self.layout = QtWidgets.QVBoxLayout(self) self.layout.addWidget(self.text) self.layout.addWidget(self.button) self.button.clicked.connect(self.magic) @QtCore.Slot()
def magic(self) :
self.text.setText(random.choice(self.hello))
if __name__ == "__main__":
app = QtWidgets.QApplication()
widget = FirstGui()
widget.resize(250.250)
widget.show()
sys.exit(app.exec_())
Copy the code
【 References 】
[1] doc. Qt. IO/qtforpython…