0

Dear pyqtgraph masters,

I want to execute pyqtgraph in a newly created process.

In my project there is a python module : trading.py. This module makes a new process using this code

p = Process(target = realDataProcess.realDataProcessStart, args=(self.TopStockList, self.requestCodeList, self.account))

And you know, To maintain pyqtgraph displaying the computer moniter, we have to use pyqt loop like below.

QApplication.instance().exec_()

But in new process, It seems that Above code doesn't work. My graph pops up and suddenly disappear.....

Is there any solution about this? please help me out.

Daniel kim
  • 158
  • 1
  • 13

2 Answers2

0

My experience with multiprocess and pyqtgraph is, that you can't create a new pyqtgraph window on new processes. Therefore, you can only use pyqtgrahp on your main process. I think there was the explanation somewhere on the net.

If you want to create additional processes to do something, besides pyqtgraph, put your pyqtgraph code below if name == 'main': Otherwise, you will have as many windows as you have processes.

0

You may want to use the class RemoteGraphicsView, which uses the Multiprocessing utility library.

Multiprocessing utility library

This library provides:

  • simple mechanism for starting a new python interpreter process that can be controlled from the original process (this allows, for example, displaying and manipulating plots in a remote process while the parent process is free to do other work)
  • proxy system that allows objects hosted in the remote process to be used as if they were local
  • Qt signal connection between processes
  • very simple in-line parallelization (fork only; does not work on windows) for number-crunching

You can actually use this class to make a graph that execute on a new process in a second window if you want.

Take a look at these two examples examples/RemoteGraphicsView.py and examples/RemoteSpeedTest.py

Ted
  • 468
  • 2
  • 8