mirror of
https://github.com/muziing/PySide6-Code-Tutorial.git
synced 2025-02-07 00:28:22 +08:00
Update 01-02
This commit is contained in:
parent
9999f72113
commit
8fce3929dc
@ -1,24 +1,22 @@
|
||||
import sys
|
||||
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class MyWidget(QtWidgets.QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("控件测试模板") # 设置窗口标题
|
||||
self.resize(800, 600) # 设置窗口大小
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.setWindowTitle("测试模板")
|
||||
self.resize(800, 600)
|
||||
self.setup_ui()
|
||||
|
||||
def setup_ui(self) -> None:
|
||||
"""设置界面"""
|
||||
# 创建一个按钮控件,其父控件为MyWidget
|
||||
button = QtWidgets.QPushButton("点击我!", self)
|
||||
button.move(300, 300) # 移动按钮控件的位置
|
||||
# 在此处编写设置UI的代码
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QtWidgets.QApplication([]) # 创建APP
|
||||
window = MyWidget() # 实例化一个MyWidget类对象
|
||||
window.show() # 显示窗口
|
||||
sys.exit(app.exec()) # 正常退出APP
|
||||
app = QtWidgets.QApplication([])
|
||||
window = MyWidget()
|
||||
window.show()
|
||||
sys.exit(app.exec())
|
||||
|
Loading…
x
Reference in New Issue
Block a user