这是使用PyQT5作为UI的首次提交,将后端和UI合并到1个工程中,统一使用了Python,没有使用JS和HTML
This commit is contained in:
52
UI/reserved/minimal_test.py
Normal file
52
UI/reserved/minimal_test.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
最小化测试,逐步创建组件
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from PyQt5.QtWidgets import QApplication, QWidget
|
||||
|
||||
# 添加项目根目录到Python路径
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
def test_step_by_step():
|
||||
print("Step 1: 创建QApplication")
|
||||
app = QApplication(sys.argv)
|
||||
print("✓ QApplication创建成功")
|
||||
|
||||
print("Step 2: 导入控制器")
|
||||
from controllers.main_controller import MainController
|
||||
print("✓ 控制器导入成功")
|
||||
|
||||
print("Step 3: 创建控制器实例")
|
||||
controller = MainController()
|
||||
print("✓ 控制器实例创建成功")
|
||||
|
||||
print("Step 4: 导入主窗口")
|
||||
from views.main_window import MainWindow
|
||||
print("✓ 主窗口导入成功")
|
||||
|
||||
print("Step 5: 创建主窗口实例")
|
||||
window = MainWindow()
|
||||
print("✓ 主窗口实例创建成功")
|
||||
|
||||
print("Step 6: 显示窗口")
|
||||
window.show()
|
||||
print("✓ 窗口显示成功")
|
||||
|
||||
print("Step 7: 进入事件循环")
|
||||
return app.exec_()
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
exit_code = test_step_by_step()
|
||||
print(f"应用程序退出,退出码: {exit_code}")
|
||||
sys.exit(exit_code)
|
||||
except Exception as e:
|
||||
print(f"发生错误: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user