这是使用PyQT5作为UI的首次提交,将后端和UI合并到1个工程中,统一使用了Python,没有使用JS和HTML
This commit is contained in:
54
UI/reserved/step_test.py
Normal file
54
UI/reserved/step_test.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
逐步构建的主程序,用于定位问题
|
||||
"""
|
||||
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
def step1_basic_window():
|
||||
"""步骤1: 创建基本窗口"""
|
||||
print("步骤1: 创建基本窗口")
|
||||
from views.main_window import MainWindow
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
return app.exec_()
|
||||
|
||||
def step2_with_controller():
|
||||
"""步骤2: 添加控制器"""
|
||||
print("步骤2: 添加控制器")
|
||||
from controllers.main_controller import MainController
|
||||
from views.main_window import MainWindow
|
||||
app = QApplication(sys.argv)
|
||||
controller = MainController()
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
return app.exec_()
|
||||
|
||||
def main():
|
||||
print("选择测试步骤:")
|
||||
print("1. 基本窗口测试")
|
||||
print("2. 带控制器的窗口测试")
|
||||
|
||||
choice = input("请输入选择 (1 或 2): ").strip()
|
||||
|
||||
if choice == "1":
|
||||
return step1_basic_window()
|
||||
elif choice == "2":
|
||||
return step2_with_controller()
|
||||
else:
|
||||
print("无效选择")
|
||||
return 1
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
exit_code = main()
|
||||
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