Skip to content
Advertisement

How to multiprocess multiple plots in a single PyQt GUI instance

I have a plot object called CrosshairPlotWidget. Each plot object spawns a thread which updates its data but these threads are still within the same main GUI process. Here’s what I currently have and an illustration:

enter image description here

1 main GUI process with 2 threads

I want to run the two plots each in a separate process, but both within the same GUI instance (same window). Essentially I’m trying to put each plot into its own separate child process to achieve true concurrency since I’m CPU bottlenecked. By having each update thread in a separate process, it will bypass Python’s global interpreter lock. Here’s an illustration of the desired goal:

1 main GUI process with 2 child processes each with its own thread

I’ve looked at

but none really help in my situation.

I also found this that does multiprocessing but not in the same GUI window.

JavaScript

Advertisement

Answer

The GUI can only live in the main thread that belongs to the main process, so what you require is not possible. As you have seen in the other examples, the closest thing to what you want is that the code that produces the live data in another process

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement