potocpav / python-concur

Concur UI Framework for Python
MIT License
48 stars 2 forks source link

Use pyodide to embed Concur into a browser #18

Open potocpav opened 4 years ago

potocpav commented 4 years ago

Mainly for documentation/presentation purposes.

https://github.com/iodide-project/pyodide

sla-te commented 3 years ago

Would be interesting for me, because as pyimgui requires OpenGL, any software using it cannot be run on the majority of all VPS/Dedicated servers, because they dont have a 3D-Capable graphics card.

Can you give some hints regarding how to embedd my app, that currently uses concur into this?

potocpav commented 3 years ago

I don't remember the specifics, but I know I gave up when I found out that quite a bit of effort was required.

I may be wrong on this, but Python in a webassembly container would need to call to JS in order to draw anything on the canvas, and to react to user events. OpenGL may need to be used for this to speed things up. This requires rewriting the integration layer in Javascript, and making it communicate with the webassembly container.

I don't know if anyone has done a similar thing? Perhaps, code from another project using ImGui would be reusable.

Once PyImGui works in the browser, adding the support to Concur-imgui should be quite trivial and I would be happy to do it.

sla-te commented 3 years ago

Hmm, I see maybe then its not what would solve my problem because we ship our application obfuscated with pyarmor including a customized embedded python, do you have any idea if it is possible to run imgui with a software renderer?

On a dedicated with the below specs I get:

GLFWError: (65542) b'WGL: The driver does not appear to support OpenGL
warnings.warn(message, GLFWError)

image

So as of now it would not be possible to run our software (or concur/pyimgui in general) on any VPS or dedicated server, not the best situation ^^

potocpav commented 3 years ago

What operating system do you run? I was able to make Concur work on a headless Linux server (Travis CI), but not on Windows. Here's the Travis config: https://github.com/potocpav/python-concur/blob/master/.travis.yml

The key part is the xvfb service. It runs a headless X server, which is used by Concur/PyImGui for drawing. All tests pass under this setup, including the ones reading pixel values from the window.

sla-te commented 3 years ago

As usual, Linux doesn't cause any problems. Sadly most "regular" users use Windows, thus our app would run on Windows, my test was done on Windows Server 2019 1809.

potocpav commented 3 years ago

It is definitely possible to implement a software renderer, but not trivial. You just have to implement a class which takes ImGui draw structures, and fills a buffer accordingly. Similar to this one, but without OpenGL. This would probably be VERY slow if implemented in Python.

EDIT: Aren't Windows headless servers configurable to allow OpenGL, similarly to xvfb?

sla-te commented 3 years ago

Ill take a close look if I can find something similar and will report back later/tomorrow.