python - pyqt signal not updating matplotlib FigureCanvasQTAgg and delayed -
i building gui pyqt4. @ moment have openglwidget()
displays geometry @ every n-th time step solver()
in different thread. added new graph window - graphwidget()
plot "some interesting" data. in solver()
utilize signal refresh open gl widget - self.updategl()
. have connected existing signal redraw figurecanvasqtagg
nil drawn. here class simulationcontrolwidget:
class simulationcontrolwidget(self): self.openglwidget = openglwidget() #opengl widget self.graphwidget = graphwidget() #plot widget matplotib # solver in new thread self.solver = solver() self._solver_thread = qthread() self._solver_thread.start() self.solver.movetothread(self._solver_thread) # signals #this signal ok okself.solver.solveode.repaintgl_signal.signal_repaintgl.connect(self.openglwidget.updategl) #this signal not ok self.solver.solveode.repaintgl_signal.signal_repaintgl.connect(self.graphwidget.plot_graph)
here class graphwidget:
class graphwidget(qtgui.qwidget): def __init__(self, mbd_system=[], parent=none, flags=0): super(graphwidget, self).__init__(parent) self.fig = figure((8.0, 4.0), dpi=100) self.canvas = figurecanvas(self.fig) self.axes = self.fig.add_subplot(111) # added button manually execute function plot_graph() self.plot_button = qtgui.qpushbutton("&show") self.layout = qtgui.qvboxlayout(self) self.layout.addwidget(self.canvas) self.layout.addwidget(self.plot_button) self.canvas.draw() # signal plot info button self.plot_button self.plot_button.clicked.connect(self.plot_graph) def plot_graph(self): print 'plotting graph!' self.axes.cla() self.axes.plot(np.random.rand(10, 2)) self.canvas.draw()
the problem have is: if manually click on button self.plot_button
function plot_graph()
executed (random info plotted correctly , text plotting_graph!
printed in eclipse pydev console). if seek execute function plot_graph()
signal text plotting_graph!
printed in console , no info plotted. have noticed if utilize signal, function plot_graph()
executing (due signal) after simulation has stopped. should solution? can set link entire code if more useful. think have synchronize this...but how?
python matplotlib pyqt pyqt4 qthread
No comments:
Post a Comment