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
| import tkinter as tk
import pickle
text = tk.Text()
n=0
texte = [("Et","Et","GN,","AP","FC"),("JH","je","GN,","AP","FC"),("me","me","GN,","AP","FC"),("KI","suis","GN,","AP","FC"),("OR","demandé","GN,","AP","FC")]
def on_click(event):
print("ok")
#text_range = text.tag_prevrange("myTag", "@%d,%d"%(event.x,event.y))
#print (text.get(*text_range))
for mot2 in texte :
if mot2[0]==mot2[1] :
text.tag_config(str(n), background="yellow", foreground="blue", underline=1)
text.insert('end', mot2[0], str(n), ' ')
text.tag_bind(str(n), '<Button-1>', on_click)
else :
text.tag_config(str(n), background="red", foreground="green", underline=1)
text.insert('end', mot2[0], str(n), ' ')
text.tag_bind(str(n), '<Button-1>', on_click)
n=n+1
text.pack()
tk.mainloop() |
Partager