pythonarcade / arcade

Easy to use Python library for creating 2D arcade games.
http://arcade.academy
Other
1.69k stars 319 forks source link

question: embedding in PySide/PyQt #1231

Closed danielhrisca closed 2 years ago

danielhrisca commented 2 years ago

Is there any possibility to embed arcade as a widget inside a PySide/PyQt application?

Cleptomania commented 2 years ago

Embedding as a widget I highly doubt it. Arcade is very dependent on Pyglet’s windowing system and hooks directly into X11/win32 for window management, and the window is at least somewhat closely tied to the OpenGL context. This functionality would probably depend more on Pyglet’s ability to run like that than Arcade(but I doubt that either is possible, at the very least with how they stand today).

Your best bet is maybe if you can live with it being a separate window you could run it as a subprocess from another application.

I doubt performance for this would look good, would depend on what your application is doing probably, but a potential concept is that Arcade is capable of running headless and can output to an image file, that you could then display inside of a Qt widget. If you were to set this up with threading/multiprocessing and use a queue you could probably just pass the image data and not have to like save/load a file to disk.

einarf commented 2 years ago

It could actually be possible. We can do this with moderngl for example. This is more a pyglet issue actually. In addition to the headless context a "detect" mode could be added that would detect a context and a framebuffer. It would have to be implemented per platform.

Still, it might not be super trivial to use in Qt because you need to be aware when the context is active and other issues such and the canvas/framebuffer being re-allocated if you are using docking features etc.

einarf commented 2 years ago

Closing this for now. This is more a pyglet thing. We might support other window libraries in the future, but this depends on pyglet entirle. It needs detect more for existing context and find a way to handle event loop.