#!/usr/bin/env python # -*- coding: utf-8 -*- from tkinter import * def factorielle(argu): # calcul de la factorielle de argu a = 1 # a contient une valeur qui va être incrémentée d'une unité à la fois b = 1 # contient la factorielle de a-1 while a<=argu: # on arrêtera lorsque a sera > argu b = b * a a = a + 1 return b def action(): texte_n = champ.get() n = int(texte_n) affichefacto.configure(text =str(factorielle(n))) root=Tk() champ = Entry(root) champ.grid(row=0) b = Button(root,text="Calcule la factorielle",command=action) b.grid(row=1) affichefacto = Label(root) affichefacto.grid(row=2) bfin = Button(root,text="Terminer",command=root.quit) bfin.grid(row=3) root.mainloop() # éliminer la fenêtre après avoir quitté : root.destroy()