Files
mvvm--learn/demo/start_up.py
2026-05-18 11:33:59 +08:00

34 lines
875 B
Python
Raw Permalink 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.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
程序入口。
运行这个文件会启动 PyQt5 应用,创建 View 和 ViewModel完成绑定
最后启动框架事件通道并进入 Qt 主事件循环。
"""
import sys
from mvvm.binder import *
if __name__ == "__main__":
# 创建 Qt 应用对象。所有 PyQt 界面程序都需要 QApplication。
app = QApplication(sys.argv)
# 创建主窗口 View负责界面控件与显示。
ui_main_win = MainWinView()
# 创建主窗口 ViewModel负责界面事件背后的逻辑。
vm_main_win = MainWinVM()
# 绑定 View 与 ViewModel。
binding_main_ui(ui_main_win, vm_main_win)
# 显示主窗口。
ui_main_win.show()
# 启动 MVVM 框架的事件循环线程。
fw_proxy.work()
# 进入 Qt 主事件循环,直到窗口关闭。
sys.exit(app.exec_())