Merge pull request 'final_update' (#126) from main into huangjiunyuna
commit
e983ded15c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
简化测试脚本 - 验证学习模式内容同步功能
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
|
||||
|
||||
from PyQt5.QtWidgets import QApplication, QTextEdit, QVBoxLayout, QWidget
|
||||
from learning_mode_window import LearningModeWindow
|
||||
|
||||
class TestWindow(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setWindowTitle("测试主窗口")
|
||||
self.setGeometry(100, 100, 600, 400)
|
||||
|
||||
# 创建布局
|
||||
layout = QVBoxLayout()
|
||||
|
||||
# 创建文本编辑器
|
||||
self.text_edit = QTextEdit()
|
||||
self.text_edit.setPlainText("初始内容\n")
|
||||
layout.addWidget(self.text_edit)
|
||||
|
||||
self.setLayout(layout)
|
||||
|
||||
# 创建学习模式窗口
|
||||
self.learning_window = LearningModeWindow(parent=self)
|
||||
self.learning_window.imported_content = "这是一段测试内容。"
|
||||
self.learning_window.current_position = 0
|
||||
self.learning_window.show()
|
||||
|
||||
# 连接内容同步信号
|
||||
self.learning_window.content_changed.connect(self.on_content_changed)
|
||||
|
||||
print("测试开始...")
|
||||
print(f"主窗口内容: {repr(self.text_edit.toPlainText())}")
|
||||
print(f"学习窗口内容: {repr(self.learning_window.imported_content)}")
|
||||
print(f"学习窗口当前位置: {self.learning_window.current_position}")
|
||||
|
||||
# 模拟用户输入正确内容
|
||||
print("\n模拟用户输入正确内容...")
|
||||
self.learning_window.current_position = 3 # 用户输入了3个字符
|
||||
self.learning_window.on_text_changed() # 调用文本变化处理
|
||||
|
||||
def on_content_changed(self, new_content, position):
|
||||
"""内容同步回调"""
|
||||
print(f"收到内容同步信号: new_content={repr(new_content)}, position={position}")
|
||||
# 在文本编辑器末尾添加新内容
|
||||
current_text = self.text_edit.toPlainText()
|
||||
self.text_edit.setPlainText(current_text + new_content)
|
||||
print(f"主窗口更新后内容: {repr(self.text_edit.toPlainText())}")
|
||||
|
||||
def test_content_sync():
|
||||
"""测试内容同步功能"""
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
test_window = TestWindow()
|
||||
test_window.show()
|
||||
|
||||
print("\n测试完成!")
|
||||
|
||||
# 运行应用
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_content_sync()
|
||||
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
测试天气生活提示功能
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 添加src目录到路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
||||
|
||||
from services.network_service import NetworkService
|
||||
|
||||
def test_weather_with_lifetips():
|
||||
"""测试包含生活提示的天气功能"""
|
||||
print("🌤 测试天气生活提示功能")
|
||||
print("=" * 50)
|
||||
|
||||
# 创建网络服务实例
|
||||
network_service = NetworkService()
|
||||
|
||||
# 获取天气信息
|
||||
print("正在获取天气信息...")
|
||||
weather_info = network_service.get_weather_info()
|
||||
|
||||
if weather_info:
|
||||
print(f"✅ 成功获取天气数据:")
|
||||
print(f"城市: {weather_info['city']}")
|
||||
print(f"温度: {weather_info['temperature']}°C")
|
||||
print(f"天气: {weather_info['description']}")
|
||||
print(f"湿度: {weather_info['humidity']}%")
|
||||
print(f"风速: {weather_info['wind_speed']}m/s")
|
||||
|
||||
# 显示生活提示
|
||||
lifetips = weather_info.get('lifetips', [])
|
||||
if lifetips:
|
||||
print(f"\n🌟 生活提示 ({len(lifetips)}条):")
|
||||
for i, tip in enumerate(lifetips, 1):
|
||||
print(f" {i}. {tip}")
|
||||
else:
|
||||
print("⚠️ 未获取到生活提示")
|
||||
|
||||
# 模拟显示详细信息格式
|
||||
print(f"\n📋 详细信息显示格式:")
|
||||
weather_text = f"{weather_info['city']}: {weather_info['temperature']}°C, {weather_info['description']}"
|
||||
weather_text += f"\n湿度: {weather_info['humidity']}%"
|
||||
weather_text += f"\n风速: {weather_info['wind_speed']}m/s"
|
||||
|
||||
if lifetips:
|
||||
weather_text += "\n\n🌟 生活提示:"
|
||||
for tip in lifetips:
|
||||
weather_text += f"\n• {tip}"
|
||||
|
||||
print(weather_text)
|
||||
|
||||
else:
|
||||
print("❌ 获取天气信息失败")
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
print("测试完成!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_weather_with_lifetips()
|
||||
Loading…
Reference in new issue