GUI via Python

Hi Chris,

I need to open a window via Python for displaying camera recording in live and I need it to be interactive for annotations. I have tried using OpenCV and PyQt6, but every time I try to open a window the MWorks server crashes. I have tried to repurpose your code from another post on the forum. However, in my case Python in MWorks doesn’t know the mworks package.

Best,
Vladyslav

Hi Vladyslav,

It’s not possible to create a GUI using embedded Python actions. The issue is that the GUI code needs to control the application’s main loop, but MWServer itself already does that, and they can’t be made to work together.

One way around this would be to use Python’s multiprocessing module to run the GUI code in a separate process. The Python code running in MWServer would launch the process and exchange needed data with it.

Another option might be to use MWClient’s Python Script Bridge instead of server-side actions. That’s the intended use of the example code your referenced; it won’t work inside MWServer. There’s a bit more info on how it works in this discussion.

Cheers,
Chris

1 Like