import Tkinter as T root = T.Tk () # moitie gauche de la fenetre f1 = T.Frame () f1.grid (column = 0, row = 0) # moitie droite de la fenetre f2 = T.Frame () f2.grid (column = 1, row = 0) # creation d'une zone de texte dans la moitie gauche (f1) l1 = T.Label (f1, text = "f(x) = ") l1.grid (column = 0, row = 0) # creation d'une zone de texte dans la moitie droite (f2) lf2 = T.Label (f2, text = "dessin de la fonction") lf2.grid (column = 0, row = 0) # creation d'une zone de saisie fonction = T.Entry (f1) fonction.grid (column = 1, row = 0) fonction.insert (0, "x**2 + x * math.cos (x)") # creation d'une zone de dessin dessin = T.Canvas (f2, width = 400, height = 400) dessin.grid (column = 0, row = 1) dessin.create_line (0,200,400,200, fill = "blue", width = 2) dessin.create_text (10,210, text = "-5", fill = "black", font = "arial") # creation d'un bouton quitter bouton = T.Button (f1, text = "quitter") bouton.grid (column = 0, row = 6) bouton.config (command = root.destroy) # creation d'un autre bouton bouton = T.Button (f1, text = "dessin") bouton.grid (column = 0, row = 2) # on associe le bouton a une fonction import random def fonction_bouton_dessin () : dessin.create_line (0,0, random.randint (0,400), random.randint (0,400)) bouton.config (command = fonction_bouton_dessin) root.mainloop ()