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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
try :
from Tkinter import *
except :
from tkinter import *
import matplotlib.pyplot as plt
def menu_graphique():
for widget in root.winfo_children():
widget.destroy()
global OA
global OAprime
global AB
titre_OA = Label(root, text="Veuillez rentrer la valeur de OA : ", font=("Comic sans MS", 20), background="#009DE0", foreground="#F8F41F")
titre_OA.pack()
OA = Entry(root, justify='center', background="#D1D0CC")
OA.pack()
titre_OAprime = Label(root, text="Veuillez rentrer la valeur de OA' : ", font=("Comic sans MS", 20), background="#009DE0", foreground="#F8F41F")
titre_OAprime.pack()
OAprime = Entry(root, justify='center', background="#D1D0CC")
OAprime.pack(pady='20')
titre_AB = Label(root, text="Veuillez rentrer la valeur de AB : ", font=("Comic sans MS", 20), background="#009DE0", foreground="#F8F41F")
titre_AB.pack()
AB = Entry(root, justify='center', background="#D1D0CC")
AB.pack()
bouton_valider = Button(root, text = "Valider", justify='center', width='20', height='1', foreground="#2113C0", background="#D1D0CC", activeforeground="#2113C0", activebackground="#848489", font=("Comic sans MS",15))
bouton_valider.bind("<ButtonRelease-1>", graphique)
bouton_valider.pack()
def graphique(event) :
plt.figure()
plt.title("Schéma : Image d'un objet par une lentille")
plt.xlabel("Δ")
plt.grid(True)
plt.plot([OA.get,OA.get], [0,AB.get], c="red", marker="^", lw="4",label="Objet AB")
plt.plot([OA.get,0], [0,0], c="blue",label="Distance OA")
plt.plot([0,OAprime.get], [0,0], c="blue",label="Distance OA'")
plt.plot([OAprime.get,OAprime.get], [0,(OAprime.get*AB.get)/(OA.get)], c="red", marker="v", lw="4",label="Image A'B'")
plt.plot([-1/(1/OAprime.get-1/OA.get),1/(1/OAprime.get-1/OA.get)], [0,0], c="black")
plt.plot([-1/(1/OAprime.get-1/OA.get),1/(1/OAprime.get-1/OA.get)], [0,0], "x", c="black", label="Distance focale")
plt.axvline(color="black", marker="^", lw="4")
plt.legend()
plt.show
def quitter():
plt.close()
fen.destroy()
def main ():
for widget in root.winfo_children():
widget.destroy()
titre = Label(root, text="Les lentilles minces convergentes", font=("Comic sans MS", 20), background="#009DE0", foreground="#F8F41F")
titre.pack()
titre_menu = Label(root, text="Menu : ", font=("Comic sans MS", 15), background="#009DE0")
titre_menu.pack()
bouton_graphique = Button(root, text="Tracer le graphique", command=menu_graphique)
bouton_graphique.pack()
root.mainloop()
root = Tk()
root.geometry("1000x600")
root.title("Les lentilles minces convergentes")
root.config(background="#009DE0")
main() |
Partager