|
@ -1,4 +1,5 @@ |
|
|
from Pile import Pile_chaine |
|
|
from Pile import Pile_chaine |
|
|
|
|
|
from tkinter import * |
|
|
|
|
|
|
|
|
class Expression: |
|
|
class Expression: |
|
|
def __init__(self, valeur, gauche, droit): |
|
|
def __init__(self, valeur, gauche, droit): |
|
@ -27,9 +28,13 @@ def dfs_post(a): |
|
|
def dfs_in(a, expstr): |
|
|
def dfs_in(a, expstr): |
|
|
if a == None: |
|
|
if a == None: |
|
|
return expstr |
|
|
return expstr |
|
|
|
|
|
if a.gauche is not None or a.droit is not None: |
|
|
|
|
|
expstr += "(" |
|
|
expstr = dfs_in(a.gauche, expstr) |
|
|
expstr = dfs_in(a.gauche, expstr) |
|
|
expstr = expstr + str(a.valeur) |
|
|
expstr += str(a.valeur) |
|
|
expstr = dfs_in(a.droit, expstr) |
|
|
expstr = dfs_in(a.droit, expstr) |
|
|
|
|
|
if a.gauche is not None or a.droit is not None: |
|
|
|
|
|
expstr += ")" |
|
|
return expstr |
|
|
return expstr |
|
|
|
|
|
|
|
|
def npi2tree(exptext): |
|
|
def npi2tree(exptext): |
|
@ -44,7 +49,24 @@ def npi2tree(exptext): |
|
|
expression.empiler(Expression(int(element), None, None)) |
|
|
expression.empiler(Expression(int(element), None, None)) |
|
|
return expression.sommet() |
|
|
return expression.sommet() |
|
|
|
|
|
|
|
|
exp = "6 4 3 * +" |
|
|
def insert(text): |
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
window = Tk() |
|
|
|
|
|
window.title("Stockfish mais pour les maths") |
|
|
|
|
|
window.geometry(f"300x400+50+50") |
|
|
|
|
|
canvas = Canvas(window, width = 300, height = 400, bg = "#abcdef") |
|
|
|
|
|
canvas.pack() |
|
|
|
|
|
lcdscreen = Entry(window, width = 35) |
|
|
|
|
|
lcdscreen.place(x=5, y=5) |
|
|
|
|
|
|
|
|
|
|
|
touches = "0 1 2 3 4 5 6 7 8 9 + * - / ^".split() |
|
|
|
|
|
|
|
|
|
|
|
for touche in touches: |
|
|
|
|
|
button = Button(window, text = touche, command = lambda touche=touche: insert(touche), bg = "#fedcba") |
|
|
|
|
|
button.place(x=touches.index(touche) // 3 * 50 + 10, y = touches.index(touche) % 3 * 50 + 100) |
|
|
|
|
|
|
|
|
|
|
|
exp = "6 4 3 + *" |
|
|
exp = npi2tree(exp) |
|
|
exp = npi2tree(exp) |
|
|
|
|
|
|
|
|
print(exp) |
|
|
print(exp) |
|
|