我用qtdesigner和python编写了一个小GUI,它应该在matplotlib图形中实时显示一个粒子的轨迹。所以我有一些类似的东西:
class DesignerMainWindow(QtGui.QMainWindow, Ui_MplMainWindow):
"""Customization for Qt Designer created window"""
def __init__(self, parent = None):
# initialization of the superclass
super(DesignerMainWindow, self).__init__(parent)
# setup the GUI --> function generated by pyuic4
self.setupUi(self)
self.niter = 30
#... other initializations
def run(self):
# set xo, yo with initial particle position
for t in range(self.niter):
# set new particle position in x, y
self.mpl.canvas.ax.plot([xo, x], [yo, y], '-b')
self.mpl.canvas.draw()
print x, y, t, self.niter
xo = x
yo = y
我的问题是,图形只在函数“run()”完成时才更新,尽管在循环中调用了“draw()”。所以我只有最后的轨迹,没有完整的电影。。。在
有人知道如何从这个函数/循环中强制图形更新吗?在
谢谢。在
尝试在} 。在
for
循环的末尾调用^{相关问题 更多 >
编程相关推荐