I'm looking for a way to fix my code. I have some code that will display a tkinter window with buttons that run code. BUT... The problem is that it will run the same line of code no matter which button is pressed.
Here is my code: Crbnk.py: (Main File)
import tkinter
import draw
import ast
#Setup
oldtiledat = None
window = tkinter.Tk()
window.title("CarbonOS 0.1 (BETA)")
window.geometry("1080x720")
tiledat = {}
tiles = []
#Clears tiles. Arguments: Tile List.
def clearTiles(tl):
    for x in tl:
        x.destroy()
        tl.remove(x)
#Redraws tiles. Arguments: Tile List, Tile Metadata. Returns new tile list
def updateTiles(tl,tls):
    clearTiles(tl)
    length = len(list(tls.keys()))
    return draw.draw(window,list(tls.keys()),list(tls.values()),range(length))
#Loads tiles. Arguments: File to load from
def loadtiles(tilefile):
    with open(tilefile,"r") as tf:
        lines = tf.readlines()
        ret = lines[0]
        ret = ret.rstrip("\n")
        ret = ast.literal_eval(ret)
    return ret
#Dumps tiles to a file. Arguments: File to write, data to save.
def savetiles(tilefile,tiledata):
    with open(tilefile,"w") as tf:
        tf.write(str(tiledata))
#Init
#get tiles into memory
tiledat = loadtiles("tile.cov")
while True:
    #Update
    window.update()
    #TileMgr (Updates if needed so no flicker)
    if oldtiledat != tiledat:
        tiles = updateTiles(tiles,tiledat)
        oldtiledat = tiledat
tile.cov (tile storage file):
{"This Prints Hi":"print('hi')","This Prints Hello":"print('hello')"}
draw.py (tile API):
import tkinter
def draw(window,names,cmd,lst):
    allb = []
    for y in lst:
        b = tkinter.Button(window, text=names[y], command=lambda: eval(cmd[y]))
        print(cmd[y])
        b.pack(side=tkinter.LEFT,anchor=tkinter.N)
        allb.append(b)
    return allb
Thanks in advance!
