Browse Source

Ajout interface Tkinter

master
FORESTIER Alexi 9 months ago
parent
commit
9d7a090cde
  1. 27
      Calc.py

27
Calc.py

@ -1,3 +1,4 @@
import tkinter as tk
from Pile import Pile_chaine
class Expression:
@ -42,10 +43,30 @@ def npi2tree(ch):
Expr.empiler(Expression(int(elmt), None, None))
return Expr.sommet()
def calculer():
expression = entry.get()
try:
resultat = npi2tree(expression).evalue()
result_label.config(text="Résultat: " + str(resultat))
except Exception as erreur:
result_label.config(text="Erreur: " + str(erreur))
ch1 = '7 4 3 * +'
exp = npi2tree(ch1)
root = tk.Tk()
root.title("Calculatrice rudimentaire")
message_label = tk.Label(root, text="Le calcul doit être écrit en notation polonaise inversée")
message_label.pack()
entry = tk.Entry(root, width=30)
entry.pack(pady=10)
evaluate_button = tk.Button(root, text="Calculer", command=calculer)
evaluate_button.pack()
result_label = tk.Label(root, text="")
result_label.pack(pady=10)
root.mainloop()

Loading…
Cancel
Save