您尚未说明发布的示例不起作用的地方。是否有错误消息?进程是否无法接收消息?绘图结果是否与您的预期有所不同?
作为最初的答案,我将推荐一种不同的方法:使用pyqtgraph的内置多处理功能。如果从主流程运行此代码,它将为您提供在新流程中运行的绘图窗口和曲线的代理。您在代理上调用的任何方法都将转发到远程进程:
import pyqtgraph as pgpg.mkQApp()# Create remote process with a plot windowimport pyqtgraph.multiprocess as mpproc = mp.QtProcess()rpg = proc._import('pyqtgraph')plotwin = rpg.plot()curve = plotwin.plot(pen='y')# create an empty list in the remote processdata = proc.transfer([])# Send new data to the remote process and plot it# We use the special argument _callSync='off' because we do# not want to wait for a return value.data.extend([1,5,2,4,3], _callSync='off')curve.setData(y=data, _callSync='off')请注意,我们在此处创建的所有对象-rpg,plotwin,曲线和数据-都是远程过程中真实对象的 代理
。因此,使用常规pyqtgraph类几乎可以执行的所有操作也可以使用这些对象来完成,并且结果将显示在远程进程中。例如:
# Local pre:win = pg.GraphicsWindow()p1 = win.addPlot()p2 = win.addPlot()# Remote pre:win = rpg.GraphicsWindow()p1 = win.addPlot()p2 = win.addPlot()
这两个示例的唯一区别是起点–本地pyqtgraph模块的pg和远程模块的rpg。



