将 Pygame 窗口与 GUI 集成 [英] Integrate Pygame window with GUI

查看:63
本文介绍了将 Pygame 窗口与 GUI 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Pyqt4,我想知道是否可以将 Pygame 窗口集成到 PQT 窗口.我一直在网上搜索,我只能找到 wxPython 或 tkinter 的集成.

Im using Pyqt4, and I was wondering if it was possible to integrate a Pygame window to a PQT window. Ive been searching the net, and I can only find integration for wxPython, or tkinter.

像这样:

我正在起诉 Pygame 3 和 Python 3.

Im suing Pygame 3 and Python 3.

提前致谢!

推荐答案

页面 http://pygame.org/wiki/gui 这很困难,如果可以,将会有严重的限制.也就是说,我还没有看到 wx 和 tkinter 是如何做到的.

The page http://pygame.org/wiki/gui this is difficult and if you can, will have severe limitations. That said, I haven't seen how wx and tkinter do it.

但我以前见过的一种方法是创建两个单独的应用程序进行通信(通过管道、UDP、共享内存、XML-RPC 等),然后主",可能是 Qt GUI,将调整大小和位置从(pygame 应用程序),所以看起来它们是集成的.您将使 pygame 应用程序无边界.如果您的 qt 应用程序不是全屏,并且用户移动窗口,您可以在移动开始时向 pygame 发送命令以隐藏自身(或最小化等),然后一旦用户将 qt 应用程序放在所需的位置,更新 pygame 应用程序位置.

But one approach I have seen before is to create two separate applications that communicate (via pipes, UDP, shared memory, XML-RPC, etc), then the "master", probably the Qt GUI, would size and position the slave (pygame app) so it looks like they are integrated. You would make the pygame app borderless. If your qt app is not full screen, and user moves window, you could send command to pygame to hide itself (or minimize or such) when move starts, then once user drops qt app in desired place, update pygame app position.

Python 的多处理模块应该使 IPC 简单明了,显得无缝.这样两个事件循环(qt 和游戏)就不会干扰,线程没有问题.

Python's multiprocessing module should make the IPC straightforward, appear seamless. And this way the two event loops (qt and game) don't interfere, no issues with threading.

这篇关于将 Pygame 窗口与 GUI 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆