【发布时间】:2015-03-16 02:57:39
【问题描述】:
我正在制作数独游戏,我需要能够检查输入的数字是否已经在行中或列中是否存在冲突。现在,这正在改变所有种子值的背景。如何检查特定条目并查看它是否已经在行或列中?
#nums_list is a 2_d list of the Entry widget id tags
#check_list are the 0's and digits of the seed values
def check_conf(self):
for r in range(0, self.height, 1):
for c in range(0, self.width, 1):
if self.nums_list[r][c].get().isdigit():
if int(self.nums_list[r][c].get()) == int(self.check_list[r][c]):
self.nums_list[r][c].config(background = 'red')
【问题讨论】:
-
.get()在做什么? -
我在 tkinter 中使用 9 x 9 的 Entry 小部件网格 .get() 正在获取 entry 小部件内的值
-
为什么需要强制转换为 int 进行比较?不完全确定您的代码在做什么,但将可能的位置作为元组存储在字典中可能更容易
-
您发布的代码有效吗?
-
我发现我正在检查文件的种子值是否等于那些显然是正确的条目。我需要为所有当前条目创建一个新列表,并检查新条目是否已经在该特定行或列中
标签: python list loops tkinter multidimensional-array