这是使用PyQT5作为UI的首次提交,将后端和UI合并到1个工程中,统一使用了Python,没有使用JS和HTML
This commit is contained in:
37
UI/reserved/test_window.py
Normal file
37
UI/reserved/test_window.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
简单的测试窗口,用于验证PyQt5环境
|
||||
"""
|
||||
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QVBoxLayout, QWidget
|
||||
|
||||
class TestWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("测试窗口")
|
||||
self.setGeometry(100, 100, 400, 300)
|
||||
|
||||
# 创建中心部件
|
||||
central_widget = QWidget()
|
||||
self.setCentralWidget(central_widget)
|
||||
|
||||
# 创建布局
|
||||
layout = QVBoxLayout(central_widget)
|
||||
|
||||
# 添加标签
|
||||
label = QLabel("如果能看到这个窗口,说明PyQt5环境正常!")
|
||||
layout.addWidget(label)
|
||||
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
window = TestWindow()
|
||||
window.show()
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user