Browse Source

Transférer les fichiers vers ''

On a représenté Stockfish graphiquement !
master
DELPUI Loïc 9 months ago
parent
commit
3d20b1327f
  1. 26
      Stockfish mais pour les maths.py

26
Stockfish mais pour les maths.py

@ -1,4 +1,5 @@
from Pile import Pile_chaine
from tkinter import *
class Expression:
def __init__(self, valeur, gauche, droit):
@ -27,9 +28,13 @@ def dfs_post(a):
def dfs_in(a, expstr):
if a == None:
return expstr
if a.gauche is not None or a.droit is not None:
expstr += "("
expstr = dfs_in(a.gauche, expstr)
expstr = expstr + str(a.valeur)
expstr += str(a.valeur)
expstr = dfs_in(a.droit, expstr)
if a.gauche is not None or a.droit is not None:
expstr += ")"
return expstr
def npi2tree(exptext):
@ -44,7 +49,24 @@ def npi2tree(exptext):
expression.empiler(Expression(int(element), None, None))
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)
print(exp)

Loading…
Cancel
Save