EG/demo/test_gui_preview_integration.py
2025-07-02 09:49:59 +08:00

71 lines
1.8 KiB
Python
Raw 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/env python3
# -*- coding: utf-8 -*-
"""
测试GUI预览窗口与主程序的集成
验证新的简化GUI编辑模式
"""
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import sys
import time
from test import MyWorld
from gui_preview_window import GUIPreviewWindow
def test_gui_preview_integration():
"""测试GUI预览窗口集成"""
print("开始测试GUI预览窗口集成...")
# 创建模拟的主程序world
world = MyWorld()
# 创建GUI预览窗口
preview = GUIPreviewWindow()
preview.set_main_world(world)
print("✓ 预览窗口已创建并连接到主程序")
# 等待一下让窗口显示
time.sleep(2)
# 在主程序中创建一些GUI元素
print("\n在主程序中创建GUI元素...")
# 创建按钮
button = world.createGUIButton((0, 0, 3), "测试按钮", 0.08)
print("✓ 已创建按钮")
time.sleep(1)
# 创建标签
label = world.createGUILabel((0, 0, 1), "测试标签", 0.06)
print("✓ 已创建标签")
time.sleep(1)
# 创建输入框
entry = world.createGUIEntry((0, 0, -1), "输入框", 0.05)
print("✓ 已创建输入框")
time.sleep(1)
# 创建3D文本
text3d = world.createGUI3DText((5, 5, 0), "3D文本", 0.5)
print("✓ 已创建3D文本")
print(f"\n主程序GUI元素总数: {len(world.gui_elements)}")
print("预览窗口应该会自动同步显示这些元素")
print("\n测试完成请查看预览窗口中的GUI元素")
print("预览窗口会自动与主程序同步")
# 运行预览窗口
if preview.preview_base:
print("\n启动预览窗口事件循环...")
preview.preview_base.run()
if __name__ == "__main__":
test_gui_preview_integration()