Event-related updates

Viewed 20

I'd like to understand why figure updates are not always applied when I click the object (button, plot area, ...). I built this minimal example to describe the problem :

import matplotlib.pyplot as plt 

fenetre=plt.figure()
plt.axes([0, 0, 1, 1])
choice1=fenetre.text(0.25, 0.75, "First choice", size=20,
                     ha="center", va="center",
                     bbox={'facecolor':'white','edgecolor':'black','pad':10})
choice2=fenetre.text(0.75, 0.75, "Second choice", size=20,
                     ha="center", va="center",
                     bbox={'facecolor':'white','edgecolor':'black','pad':10})
result=fenetre.text(0.5, 0.3, "Text here ?", size=30,ha="center", va="center")

def click(event) :
    text="Click at (%f,%f)"%(event.xdata,event.ydata)
    result.set_text(text)   
    print(text)
    
plt.connect('button_press_event', click)

The text is printed in the console, but the text object is not updated. Can someone light my candle ?

0 Answers
Related