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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
| from tkinter import *
from tkinter import ttk
import tkinter.font
import PIL
import numpy
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from math import sqrt
import math
import os
clear = lambda: os.system('cls')
#-------------------------------fonction pour les calculs---------------------------
#Calcul du discriminant
def discriminant():
delta = float(b2.get())**2 - 4*float(a2.get())*float(c2.get())
return delta
#Recherche des racines
def recherche_racines():
delta = discriminant()
#1 solution reelle
if delta == 0:
x= "%.2f" %(-float(b2.get()) / (2*float(a2.get())))
Resultat.config(text = str(x))
#2 solutions reelles
elif delta > 0:
racine_carre_delta = sqrt(delta)
x1 = "%.2f" % (float(-float(b2.get()) + racine_carre_delta) / (2*float(a2.get())))
x2 = "%.2f" %(float(-float(b2.get()) - racine_carre_delta) / (2*float(a2.get())))
Resultat.config(text = str(x1)+str(x2))
#2 solutions complexes
elif delta < 0:
racine_carre_delta = sqrt(-delta)
x1 = complex(-float(b2.get()), racine_carre_delta) / (2*float(a2.get()))
x2 = complex(-float(b2.get()), -racine_carre_delta) / (2*float(a2.get()))
Resultat.config(text = str(x1)+str(x2))
#Recherche coefficient directeur avec 2 points
def recherche_coefficient_directeur(x1,y1,x2,y2):
return (y2-y1)/(x2-x1)
#Equation de trajectoire d'une parabole
#Fonction pour convertir les radians en degres
def convertir_radians_degres(a):
return a*math.pi/180
def calcul_ordonnee_from_abscisse(x,z1,z2,z3):
return z1*x*x + z2*x + z3
#param:
#a: angle alpha
#v: vitesse initiale
#h: hauteur de depart
def recherche_coef_trajectoire():
z1 = float("%.2f" % (-9.80665 / (2*float(a2.get())*float(a2.get())*(math.cos(convertir_radians_degres(float(b2.get())))*(math.cos(convertir_radians_degres(float(b2.get()))))))))
z2 = float("%.2f" % math.tan(convertir_radians_degres(float(b2.get()))))
z3 = float(c2.get())
tabX = []
tabY = []
x = 0
while(calcul_ordonnee_from_abscisse(x,z1,z2,z3) >= 0):
tabX.append(x)
tabY.append(calcul_ordonnee_from_abscisse(x,z1,z2,z3))
x = x + 0.001
f = Figure(figsize=(5,4), dpi=70)
plt = f.add_subplot(111)
plt.plot(tabX,tabY)
canvas = FigureCanvasTkAgg(f, master=p2)
canvas.get_tk_widget().place(x=150, y =200)
toolbar = NavigationToolbar2TkAgg(canvas, p2)
toolbar.update()
toolbar.place(x= 150, y=500)
# a tk.DrawingArea
Resultat.config(text = "La trajectoire prise par l'objet nous donne l'equation suivante: " + str(z1) + "x² + " + str(z2) + "x + " + str(z3))
#param:
#x: abscisse de la courbe
#fonction pour changer le panneau de droite (p2)
def mise_a_jour(event):
if lP.curselection() == ('1',) :
global presentation
global a1
global a2
global b1
global b2
global c1
global c2
global button1
global label_resultat
global Resultat
presentation.destroy()
a1.place_forget()
a2.place_forget()
b1.place_forget()
b2.place_forget()
c1.place_forget()
c2.place_forget()
button1.place_forget()
label_resultat.place_forget()
Resultat.place_forget()
presentation = Label(p2, text="Cette fonction vous permet d'obtenir l'équation de la parabole et sa représentation graphique,\nEntrez la vitesse, l'angle d'incidence et la hauteur de départ", justify=LEFT)
presentation.place(x= 20, y=20)
a1 = Label(p2, text="Entrez la vitesse en m/s :")
a1.place(x= 50, y=80)
a2 = Entry(p2)
a2.place(x= 190, y=80)
b1 = Label(p2, text="Entrez l'angle en degrés :")
b1.place(x= 50, y=110)
b2= Entry(p2)
b2.place(x= 190, y=110)
c1 = Label(p2, text="Entrez la hauteur en m :")
c1.place(x= 50, y=140)
c2 = Entry(p2)
c2.place(x= 190, y=140)
button1 = Button(p2, text='Calculer', command=recherche_coef_trajectoire)
button1.place(height=50, width=100, x=360, y=95)
label_resultat = Label(p2, text="Voici le résultat :")
label_resultat.place(x=50, y=170)
Resultat = Label(p2, text="je suis la ")
Resultat.place(x=150, y=170)
elif lM.curselection() == ('0',) :
global presentation
global a1
global a2
global b1
global b2
global c1
global c2
global button1
global label_resultat
global Resultat
global canvas
global toolbar
presentation.destroy()
a1.place_forget()
a2.place_forget()
b1.place_forget()
b2.place_forget()
c1.place_forget()
c2.place_forget()
button1.place_forget()
label_resultat.place_forget()
Resultat.place_forget()
toolbar.place_forget()
canvas.get_tk_widget().place_forget()
#------------------------Equation second degré-------------------------
presentation = Label(p2, text="Cette fonction vous permet d'obtenir les solutions d'une equation du second degré, pour ax² + bx + c,\nEntrez les valeurs a, b et c :", justify=LEFT)
presentation.place(x= 20, y=20)
a1 = Label(p2, text="Entrez a :")
a1.place(x= 50, y=80)
a2 = Entry(p2)
a2.place(x= 110, y=80)
b1 = Label(p2, text="Entrez b :")
b1.place(x= 50, y=110)
b2 = Entry(p2)
b2.place(x= 110, y=110)
c1 = Label(p2, text="Entrez c :")
c1.place(x= 50, y=140)
c2 = Entry(p2)
c2.place(x= 110, y=140)
button1 = Button(p2, text='Calculer', command=recherche_racines)
button1.place(height=50, width=100, x=300, y=95)
label_resultat = Label(p2, text="Voici le résultat :")
label_resultat.place(x=200, y=300)
Resultat = Label(p2, text="je suis la ")
Resultat.place(x=300, y=300)
#------------------------TKINTER-------------------------
fenetre = Tk()
fenetre.iconbitmap('icone.ico')
fenetre.title("Calculator")
police=tkinter.font.Font(fenetre, size=12, family='Helvetica')
n = ttk.Notebook(fenetre)
f1 = ttk.Frame(n, width=900, height=570, padding=(10,10,10,10));
f2 = ttk.Frame(n, width=900, height=570, padding=(10,10,10,10));
n.add(f1, text='Fonction')
n.add(f2, text='Quizz')
n.pack()
s = ttk.Style()
s.configure('My.TFrame', background='#D8D8D9')
p = ttk.Panedwindow(f1, orient=HORIZONTAL)
p1 = ttk.Labelframe(p, text='Choix Fonction', width=200, height=570)
p2 = ttk.Labelframe(p, text='Fonctions', width=700, height=570);
p.add(p1)
p.add(p2)
p.pack()
p2.pack_propagate(False)
# Liste de fonction Mathématiques :
titre_liste_fonctionM = Label(p1, text="Mathématiques :", )
titre_liste_fonctionM.pack(anchor=W)
lM = Listbox(p1, height=10, width=25)
lM.bind("<ButtonRelease-1>", mise_a_jour)
lM.pack()
lM.insert(END,)
for item in [" Equation 2nd Degré", " Coefficient directeur", " Fonction3", " Fonction4"]:
lM.insert(END, item)
fonction = ('test','dsdlkjg','fldiu')
for i in range(0,len(fonction),2):
lM.itemconfigure(i, background="#DDDDFF")
i=lM.curselection()
print(i)
# Liste de fonction Physique :
titre_liste_fonctionP = Label(p1, text="Physique :")
titre_liste_fonctionP.pack(anchor=W)
lP = Listbox(p1, height=10, width=25)
lP.bind("<ButtonRelease-1>", mise_a_jour)
lP.pack()
lP.insert(END,)
for item in [" Vitesse d'un satellite", " Equation d'une Parabole", " Fonction3", " Fonction4"]:
lP.insert(END, item)
fonction = ('test',recherche_coef_trajectoire,'fldiu')
for i in range(0,len(fonction),2):
lP.itemconfigure(i, background="#DDDDFF")
label = Label(fenetre, text="CALCULATOR 2.5.5. Copyright 2001", font=police)
label.pack()
fenetre.resizable(width=False, height=False)
#------------------------Panneau Courbe vitesse-------------------------
presentation = Label(p2, text="Cette fonction vous permet d'obtenir l'équation de la parabole et sa représentation graphique,\nEntrez la vitesse, l'angle d'incidence et la hauteur de départ", justify=LEFT)
presentation.place(x= 20, y=20)
a1 = Label(p2, text="Entrez la vitesse en m/s :")
a1.place(x= 50, y=80)
a2 = Entry(p2)
a2.place(x= 190, y=80)
b1 = Label(p2, text="Entrez l'angle en degrés :")
b1.place(x= 50, y=110)
b2= Entry(p2)
b2.place(x= 190, y=110)
c1 = Label(p2, text="Entrez la hauteur en m :")
c1.place(x= 50, y=140)
c2 = Entry(p2)
c2.place(x= 190, y=140)
button1 = Button(p2, text='Calculer', command=recherche_coef_trajectoire)
button1.place(height=50, width=100, x=360, y=95)
label_resultat = Label(p2, text="Voici le résultat :")
label_resultat.place(x=50, y=170)
Resultat = Label(p2, text="je suis la ")
Resultat.place(x=150, y=170)
f = Figure(figsize=(5,4), dpi=70, facecolor='none')
canvas = FigureCanvasTkAgg(f, master=p2)
canvas.get_tk_widget().place(x=150, y =200)
toolbar = NavigationToolbar2TkAgg(canvas, p2)
toolbar.place(x= 150, y=500)
fenetre.mainloop() |
Partager