Your problem is in the onclick
function.
def onclick(event):
print event.__class__
wedge = event.artist
label = wedge.get_label()
print label
fig.canvas.figure.clf()
ax=fig.add_subplot(111)
wedges, plt_labels = ax.pie([50, 100, 60],labels=labels)
fig.canvas.draw()
Here you are creating new wedges
(which overwrite your old wedges
instances) and you are not setting them to be pickable. A quick patch for this is to change onclick
to:
def onclick(event):
print event.__class__
wedge = event.artist
label = wedge.get_label()
print label
fig.canvas.figure.clf()
ax=fig.add_subplot(111)
wedges, plt_labels = ax.pie([50, 100, 60],labels=labels)
fig.canvas.draw()
for wedge in wedges:
wedge.set_picker(True)