May-24-2020, 12:08 PM
I am working through a coding book with my child and we cannot figure out why we are getting errors. We have written other code using IDLE where we have imported tkinter and it has worked on our laptop.
Here is our code so far
Here is our code so far
import tkinter import random gameOver = False score = 0 SquaresToClear = 0 def play_bombdodger(): create_bombfield(bombfield) window=tkinter.TK() layout_window(window) window.mainloop() bombfield = [] def create_bombfield(bombfield): global squaresToClear for row in range(0,10): rowList=[] for column in range(0,10): if random.randint(1,100) < 20: rowList.append(1) else: rowList.append(0) squaresToClear = squaresToClear + 1 bombfield.append(rowList) printfield(bombfield) def printfield(bombfield): for rowList in bombfield: print(rowList) def layout_window(window): for rowNumber, rowList in enumerate (bombfield): for columnNumber, columnEntry in enumerate (rowList): if random.randint(1,100)<25: square=tkinter.Label(Window, text=" ",bg= "darkgreen") elif random.randint(1,100)>75: square=tkinter.Label(window, text= " ", bg = "seagreen") else: square = tkinter.Label(window,text=" ", bg="green") square.grid(row.grid(row=rowNumber,column=columnNumber) square.bind("<button-1>", on_click) play_bombdodger()Basically nothing is happening for us. We are not seeing a map of bombs in the shell window, and we are also not getting a square of green shades. We are reluctant to proceed further with making this game because of the errors.