1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import matplotlib.pyplot as plt
from matplotlib.gridspec import Gridspec
from matplotlib.widegt import Button,Radiobuttons,Slider,TextBox
a =0
fen = plt.figure(figsize=(15,10),dpi=100,num='Fenetre')
fen.set_facecolor('white')
gs = GridSpec(100,100)
plt.subplot_adjust(left=0.05,right=0.95,bottom=0.05,top=0.95)
#bouton1#
bouton1 = fen.add_subplot(gs[15:25,3:13])
bouton1 = Button(bouton1,'+2',color='red',hovercolor='red')
bouton1.label.set_fontsize(20)
#+2#
boite = fen.add_subplot(gs[0:10,3:13])
boite_box = TextBox(boite,"",color='white',hovercolor='white')
texte = plt.text(0.5,0.5,'0',ha='center',va='center',fontsize='14')
def test (event):
global a
a=a+2
print(a)
text.set_text(a)
return a
bouton1.on_clicked(test)
plot.show() |
Partager