LINUX.ORG.RU

История изменений

Исправление thunar, (текущая версия) :

Пока как-то так получилось:

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg

class osc_ui(object):

	def __init__(self, rows):
		self.win = pg.GraphicsLayoutWidget(show=True)
		self.axs = [self.win.addPlot(col=0,row=i) for i in range(rows)]
		self.plt = [ax.plot() for ax in self.axs]
		for ax in self.axs[1:]:
			ax.setXLink(self.axs[0])
		
	def update(self, x, *ys):
		for plot,y in zip(self.plt, ys):
			plot.setData(x, y)
		pg.QtGui.QApplication.processEvents()

def gen_data():
	xs = np.linspace(-10,10,10001)
	ys = np.random.normal(0,1,size=xs.shape)
	zs = np.random.normal(0,1,size=xs.shape)
	time.sleep(1/10)
	return xs,ys,zs

if __name__ == '__main__':

	ui = osc_ui(2)
	while True:
		print("gen data, ",end="")
		data = gen_data()
		
		print("redraw")
		ui.update(*data)
Но это в текущем треде, так, конечно, теряется интерактивность.

Исправление thunar, :

Пока как-то так получилось:

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg

class osc_ui(object):

	def __init__(self, rows):
		self.win = pg.GraphicsLayoutWidget(show=True)
		self.axs = [self.win.addPlot(col=0,row=i) for i in range(rows)]
		self.plt = [ax.plot() for ax in self.axs]
		for ax in self.axs[1:]:
			ax.setXLink(self.axs[0])
		
	def update(self, x, *ys):
		for plot,y in zip(self.plt, ys):
			plot.setData(x, y)
		pg.QtGui.QApplication.processEvents()

def gen_data():
	xs = np.linspace(-10,10,10001)
	ys = np.random.normal(0,1,size=xs.shape)
	zs = np.random.normal(0,1,size=xs.shape)
	time.sleep(1/10)
	return xs,ys,zs

if __name__ == '__main__':

	ui = osc_ui(2)
	while True:
		print("gen data, ",end="")
		data = gen_data()
		
		print("redraw")
		ui.update(*data)

Исправление thunar, :

Пока как-то так получилось:

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
class osc_ui(object):

	def __init__(self, rows):
		self.win = pg.GraphicsLayoutWidget(show=True)
		self.axs = [self.win.addPlot(col=0,row=i) for i in range(rows)]
		self.plt = [ax.plot() for ax in self.axs]
		for ax in self.axs[1:]:
			ax.setXLink(self.axs[0])
		
	def update(self, x, *ys):
		for plot,y in zip(self.plt, ys):
			plot.setData(x, y)
		pg.QtGui.QApplication.processEvents()

def gen_data():
	xs = np.linspace(-10,10,10001)
	ys = np.random.normal(0,1,size=xs.shape)
	zs = np.random.normal(0,1,size=xs.shape)
	time.sleep(1/10)
	return xs,ys,zs

if __name__ == '__main__':

	ui = osc_ui(2)
	while True:
		print("gen data, ",end="")
		data = gen_data()
		
		print("redraw")
		ui.update(*data)

Исходная версия thunar, :

Пока как-то так получилось:

class osc_ui(object):

	def __init__(self, rows):
		self.win = pg.GraphicsLayoutWidget(show=True)
		self.axs = [self.win.addPlot(col=0,row=i) for i in range(rows)]
		self.plt = [ax.plot() for ax in self.axs]
		for ax in self.axs[1:]:
			ax.setXLink(self.axs[0])
		
	def update(self, x, *ys):
		for plot,y in zip(self.plt, ys):
			plot.setData(x, y)
		pg.QtGui.QApplication.processEvents()

def gen_data():
	xs = np.linspace(-10,10,10001)
	ys = np.random.normal(0,1,size=xs.shape)
	zs = np.random.normal(0,1,size=xs.shape)
	time.sleep(1/10)
	return xs,ys,zs

if __name__ == '__main__':

	ui = osc_ui(2)
	while True:
		print("gen data, ",end="")
		data = gen_data()
		
		print("redraw")
		ui.update(*data)