|
|
@ -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)) |
|
|
|
|
|
|
|
root = tk.Tk() |
|
|
|
root.title("Calculatrice rudimentaire") |
|
|
|
|
|
|
|
ch1 = '7 4 3 * +' |
|
|
|
exp = npi2tree(ch1) |
|
|
|
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() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|