PySide6-Code-Tutorial/01-HelloWorld-基本结构/02-MinimumTestFrame-最小框架.py
2022-06-05 08:35:48 +08:00

25 lines
738 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import sys
from PySide6 import QtWidgets
class MyWidget(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("控件测试模板") # 设置窗口标题
self.resize(800, 600) # 设置窗口大小
self.setup_ui()
def setup_ui(self) -> None:
"""设置界面"""
# 创建一个按钮控件其父控件为MyWidget
button = QtWidgets.QPushButton("点击我!", self)
button.move(300, 300) # 移动按钮控件的位置
if __name__ == "__main__":
app = QtWidgets.QApplication([]) # 创建APP
window = MyWidget() # 实例化一个MyWidget类对象
window.show() # 显示窗口
sys.exit(app.exec()) # 正常退出APP