在python matplotlib中显示带有“下一步”和“上一步”按钮的图像序列
我有一个图像序列,我想一个接一个地显示它们,并允许用户使用matplotlib中的“下一个”和“上一个”按钮在图像之间导航。 这是我的密码:在python matplotlib中显示带有“下一步”和“上一步”按钮的图像序列,python,matplotlib,Python,Matplotlib,我有一个图像序列,我想一个接一个地显示它们,并允许用户使用matplotlib中的“下一个”和“上一个”按钮在图像之间导航。 这是我的密码: fig, ax = plt.subplots() class Index(object): ind = 0 def next(self, event): self.ind += 1 print self.ind orig_frame = cv2.imread(FFMPEG_PATH + all_frames[sel
fig, ax = plt.subplots()
class Index(object):
ind = 0
def next(self, event):
self.ind += 1
print self.ind
orig_frame = cv2.imread(FFMPEG_PATH + all_frames[self.ind])
ax.imshow(orig_frame)
def prev(self, event):
self.ind -= 1
orig_frame = cv2.imread(FFMPEG_PATH + all_frames[self.ind])
ax.imshow(orig_frame)
callback = Index()
axnext = plt.axes([0.8, 0.7, 0.1, 0.075])
axprev = plt.axes([0.8, 0.6, 0.1, 0.075])
next_button = Button(axnext, 'Next')
next_button.on_clicked(callback.next)
prev_button = Button(axprev, 'Previous')
prev_button.on_clicked(callback.prev)
plt.show()
plt.waitforbuttonpress()
问题是,只要我单击“下一步”按钮,它就不会显示任何内容,程序会立即终止。我该怎么办