这是使用PyQT5作为UI的首次提交,将后端和UI合并到1个工程中,统一使用了Python,没有使用JS和HTML
This commit is contained in:
54
UI/reserved/simple_full_test.py
Normal file
54
UI/reserved/simple_full_test.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
不依赖数据库的简化测试版本
|
||||
"""
|
||||
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
|
||||
|
||||
# 简化的模型
|
||||
class SimpleTestModel(QObject):
|
||||
dataChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self._test_data = [
|
||||
{"id": 1, "name": "测试1", "dutDirectionMode": 2, "status": "运行中"},
|
||||
{"id": 2, "name": "测试2", "dutDirectionMode": 1, "status": "待开始"},
|
||||
{"id": 3, "name": "测试3", "dutDirectionMode": 2, "status": "已完成"}
|
||||
]
|
||||
self._filtered_data = [item for item in self._test_data if item.get("dutDirectionMode") == 2]
|
||||
|
||||
@pyqtProperty('QVariant', notify=dataChanged)
|
||||
def filteredTestData(self):
|
||||
return self._filtered_data
|
||||
|
||||
# 简化的控制器
|
||||
class SimpleController(QObject):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self._test_model = SimpleTestModel()
|
||||
|
||||
@pyqtProperty('QObject*', constant=True)
|
||||
def testModel(self):
|
||||
return self._test_model
|
||||
|
||||
# 简化的主程序
|
||||
def main():
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# 创建控制器
|
||||
controller = SimpleController()
|
||||
|
||||
# 创建窗口(这里用简单的窗口代替)
|
||||
from views.main_window import MainWindow
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
|
||||
return app.exec_()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user