Integrate Pygame window with GUI

懵懂的女人 提交于 2019-12-23 04:44:02

问题


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.

Something like this:

Im suing Pygame 3 and Python 3.

Thanks in advance!


回答1:


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.

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'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.



来源:https://stackoverflow.com/questions/21645577/integrate-pygame-window-with-gui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!