import tkinter

cat = [
[1, 0, 0, 0, 0, 0, 7, 7],
[0, 2, 0, 0, 0, 0, 7, 7],
[0, 0, 3, 0, 0, 0, 0, 0],
[0, 0, 0, 4, 0, 0, 0, 0],
[0, 0, 0, 0, 5, 0, 0, 0],
[0, 0, 0, 0, 0, 6, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 2, 3, 4, 5, 6]
]

def draw_cat():
    for y in range(10):
        for x in range(8):
            if cat[y][x] > 0:
                cvs.create_image(x * 72 + 60, y * 72 + 60, image = img_cat[cat[y][x]])

root = tkinter.Tk()
root.title('利用二維列表管理格子')
root.resizable(False, False)
cvs = tkinter.Canvas(root, width = 912, height = 768)
cvs.pack()

bg = tkinter.PhotoImage(file = 'images/cat_bg.png')

img_cat = [
    None,
    tkinter.PhotoImage(file = 'images/cat1.png'),
    tkinter.PhotoImage(file = 'images/cat2.png'),
    tkinter.PhotoImage(file = 'images/cat3.png'),
    tkinter.PhotoImage(file = 'images/cat4.png'),
    tkinter.PhotoImage(file = 'images/cat5.png'),
    tkinter.PhotoImage(file = 'images/cat6.png'),
    tkinter.PhotoImage(file= 'images/cat_paw.png')
]

cvs.create_image(456, 384, image = bg)
draw_cat()
root.mainloop()
