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
| from tkinter import *
from tkinter import ttk
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
def courbe():
m=float(a.get())
n=float(b.get())
o=float(c.get())
fig1 = Figure(figsize=(8, 8), dpi=120)
fig1.patch.set_facecolor("#82B4BF")
ax = fig1.subplots()
x = np.arange(-10, 10, 0.2)
y = m*x**2+n*x+o
ax.plot(x, y, linewidth=0.8)
canvas = FigureCanvasTkAgg(fig1, master=window_p)
canvas.get_tk_widget().pack()
canvas.draw()
window_p = Tk()
window_p.title("fonction y=ax²+bx+c")
window_p.geometry("1200x800")
window_p.config(background="#82B4BF")
frame1 = Frame(window_p, background="#82B4BF", borderwidth=2, relief=GROOVE)
frame1.config(width=135, height=190)
frame1.pack(side=LEFT)
label_titre = Label(frame1, text="Valeurs", font=("Helvetica", 12), bg="#82B4BF")
label_titre.place(x=30, y=10)
label_a = Label(frame1, text="a :", font=("Helvetica", 12), bg="#82B4BF")
label_a.place(x=20, y=45)
a = StringVar()
a_entry = Entry(frame1, textvariable=a, width=4, justify="center", font=("Helvetica", 12))
a_entry.place(x=70, y=45)
label_b = Label(frame1, text="b :", font=("Helvetica", 12), bg="#82B4BF")
label_b.place(x=20, y=75)
b = StringVar()
b_entry = Entry(frame1, textvariable=b, width=4, justify="center", font=("Helvetica", 12))
b_entry.place(x=70, y=75)
label_c = Label(frame1, text="c :", font=("Helvetica", 12), bg="#82B4BF")
label_c.place(x=20, y=105)
c = StringVar()
c_entry = Entry(frame1, textvariable=c, width=4, justify="center", font=("Helvetica", 12))
c_entry.place(x=70, y=105)
bouton_calcul = Button(frame1, text="TRACER", font=("Helvetica", 10), command=courbe)
bouton_calcul.place(x=30, y=145)
window_p.mainloop() |
Partager