import tkinter
import random
from tkinter import messagebox
size1 = 0
gameOver = False
score = 0
squaresToClear = 0
choice = True
def yes():
global choice
choice = True
def no():
global choice
choice = False
#the game runner
def play_bombdodger(size):
#asking for the map
MsgBox = tkinter.messagebox.askquestion ('map','do you want a map',icon = 'question')
if MsgBox == 'yes':
tkinter.messagebox.showinfo('map', 'CHEATER! Or not but you USE a MAP!',icon = 'warning')
yes()
else:
tkinter.messagebox.showinfo('map','you will not have a map',icon = 'info')
no()
global size1
size1 = size
window = tkinter.Tk()
create_bombfield(bombfield)
layout_window(window)
window.mainloop()
bombfield = []
#creates the bombfield
def create_bombfield(bombfield):
global squaresToClear
for row in range(size1):
rowList = []
for column in range(size1):
if random.randint(1,100) < 20:
rowList.append(1)
else:
rowList.append(0)
squaresToClear = squaresToClear + 1
bombfield.append(rowList)
if choice == True :
printfield(bombfield)
def printfield(bombfield):
for rowList in bombfield:
print(rowList)
def layout_window(window):
#here is the error happening
for rowNumber, rowList 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 = "green")
else:
square = tkinter.Label(window, text=" ", bg = "seagreen")
square.grid(row = rowNumber, column = columnNumber)
play_bombdodger('an int')
所以有人可以帮助我摆脱以下错误: 追溯(最近一次通话): 文件“”,第1行,位于 play_bombdodger(3) 在play_bombdodger中,文件“ /home/henry/bombdodger.py”,第27行 layout_window(窗口) 在layout_window中的文件“ /home/henry/bombdodger.py”,第48行 对于rowNumber,enumerate(rowList)中的rowList: TypeError:“ int”对象不可迭代