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 34 35
|
from Tkinter import *
fen = Tk()
fen.title("Test")
fen.geometry("600x600")
fen.frame = Frame(fen)
variable = Entry(fen)
def reponse():
result = []
question = variable.get()
recherche = question.split()
mots = ['salut', 'toi', 'comment', 'va', 'tu', 'te', 'mec']
for resultat in recherche:
for entree in mots:
if resultat in entree:
result.append(resultat)
try:
fen.retour
except:
print 'la variable n\'existe pas'
else:
fen.retour.destroy()
final = ' '.join(result)
fen.retour = Label(fen,text=final ,foreground="red",width=100)
fen.retour.pack()
fen.boutton = Button(fen,text="valider",command=reponse)
variable.pack()
fen.boutton.pack()
fen.mainloop() |
Partager