0

我一直在使用数独求解器,在最终创建了一个解决它们的递归算法之后,我用 Tkinter 创建了一个 GUI。

问题是创建一个要求用户输入值的网格大约有 300 行长。必须有一种方法可以更快地做到这一点。

同样,现在我写了所有这些行,我需要一个由按钮小部件组成的相等网格,当按下空按钮时显示原始数字或什么都不显示我想在按钮上显示数独中该位置的已解决值. (我也喜欢底部的按钮,它将所有空按钮转换为它们的值。)

我的输入代码:

class Sudoku:
    def __init__(self, master):
        self.master = master
        fr = LabelFrame(master, text='Sudoku Solver')
        fr.grid(row=0, column=0, padx=8, pady=8, sticky=W)

        fr1 = LabelFrame(fr)
        fr1.grid(row=0, column=0, padx=1, pady=1, sticky=W)

        self.name11 = IntVar()
        self.namefield11 = Entry(fr1, width=3, textvariable= self.name11)
        self.namefield11.grid(row= 0, column=1, sticky= W)

        self.name12 = IntVar()
        self.namefield12 = Entry(fr1, width=3, textvariable= self.name12)
        self.namefield12.grid(row= 0, column=2, sticky= W)

        self.name13 = IntVar()
        self.namefield13 = Entry(fr1, width=3, textvariable= self.name13)
        self.namefield13.grid(row= 0, column=3, sticky= W)

        self.name14 = IntVar()
        self.namefield14 = Entry(fr1, width=3, textvariable= self.name14)
        self.namefield14.grid(row= 1, column=1, sticky= W)

        self.name15 = IntVar()
        self.namefield15 = Entry(fr1, width=3, textvariable= self.name15)
        self.namefield15.grid(row= 1, column=2, sticky= W)

        self.name16 = IntVar()
        self.namefield16 = Entry(fr1, width=3, textvariable= self.name16)
        self.namefield16.grid(row= 1, column=3, sticky= W)

        self.name17 = IntVar()
        self.namefield17 = Entry(fr1, width=3, textvariable= self.name17)
        self.namefield17.grid(row= 2, column=1, sticky= W)

        self.name18 = IntVar()
        self.namefield18 = Entry(fr1, width=3, textvariable= self.name18)
        self.namefield18.grid(row= 2, column=2, sticky= W)

        self.name19 = IntVar()
        self.namefield19 = Entry(fr1, width=3, textvariable= self.name19)
        self.namefield19.grid(row= 2, column=3, sticky= W)

        fr2 = LabelFrame(fr)
        fr2.grid(row=0, column=1, padx=1, pady=1, sticky=W)

        self.name21 = IntVar()
        self.namefield21 = Entry(fr2, width=3, textvariable= self.name21)
        self.namefield21.grid(row= 0, column=1, sticky= W)

        self.name22 = IntVar()
        self.namefield22 = Entry(fr2, width=3, textvariable= self.name22)
        self.namefield22.grid(row= 0, column=2, sticky= W)

        self.name23 = IntVar()
        self.namefield23 = Entry(fr2, width=3, textvariable= self.name23)
        self.namefield23.grid(row= 0, column=3, sticky= W)

        self.name24 = IntVar()
        self.namefield24 = Entry(fr2, width=3, textvariable= self.name24)
        self.namefield24.grid(row= 1, column=1, sticky= W)

        self.name25 = IntVar()
        self.namefield25 = Entry(fr2, width=3, textvariable= self.name25)
        self.namefield25.grid(row= 1, column=2, sticky= W)

        self.name26 = IntVar()
        self.namefield26 = Entry(fr2, width=3, textvariable= self.name26)
        self.namefield26.grid(row= 1, column=3, sticky= W)

        self.name27 = IntVar()
        self.namefield27 = Entry(fr2, width=3, textvariable= self.name27)
        self.namefield27.grid(row= 2, column=1, sticky= W)

        self.name28 = IntVar()
        self.namefield28 = Entry(fr2, width=3, textvariable= self.name28)
        self.namefield28.grid(row= 2, column=2, sticky= W)

        self.name29 = IntVar()
        self.namefield29 = Entry(fr2, width=3, textvariable= self.name29)
        self.namefield29.grid(row= 2, column=3, sticky= W)


        fr3 = LabelFrame(fr)
        fr3.grid(row=0, column=2, padx=1, pady=1, sticky=W)

        self.name31 = IntVar()
        self.namefield31 = Entry(fr3, width=3, textvariable= self.name31)
        self.namefield31.grid(row= 0, column=1, sticky= W)

        self.name32 = IntVar()
        self.namefield32 = Entry(fr3, width=3, textvariable= self.name32)
        self.namefield32.grid(row= 0, column=2, sticky= W)

        self.name33 = IntVar()
        self.namefield33 = Entry(fr3, width=3, textvariable= self.name33)
        self.namefield33.grid(row= 0, column=3, sticky= W)

        self.name34 = IntVar()
        self.namefield34 = Entry(fr3, width=3, textvariable= self.name34)
        self.namefield34.grid(row= 1, column=1, sticky= W)

        self.name35 = IntVar()
        self.namefield35 = Entry(fr3, width=3, textvariable= self.name35)
        self.namefield35.grid(row= 1, column=2, sticky= W)

        self.name36 = IntVar()
        self.namefield36 = Entry(fr3, width=3, textvariable= self.name36)
        self.namefield36.grid(row= 1, column=3, sticky= W)

        self.name37 = IntVar()
        self.namefield37 = Entry(fr3, width=3, textvariable= self.name37)
        self.namefield37.grid(row= 2, column=1, sticky= W)

        self.name38 = IntVar()
        self.namefield38 = Entry(fr3, width=3, textvariable= self.name38)
        self.namefield38.grid(row= 2, column=2, sticky= W)

        self.name39 = IntVar()
        self.namefield39 = Entry(fr3, width=3, textvariable= self.name39)
        self.namefield39.grid(row= 2, column=3, sticky= W)


        fr4 = LabelFrame(fr)
        fr4.grid(row=1, column=0, padx=1, pady=1, sticky=W)

        self.name41 = IntVar()
        self.namefield41 = Entry(fr4, width=3, textvariable= self.name41)
        self.namefield41.grid(row= 0, column=1, sticky= W)

        self.name42 = IntVar()
        self.namefield42 = Entry(fr4, width=3, textvariable= self.name42)
        self.namefield42.grid(row= 0, column=2, sticky= W)

        self.name43 = IntVar()
        self.namefield43 = Entry(fr4, width=3, textvariable= self.name43)
        self.namefield43.grid(row= 0, column=3, sticky= W)

        self.name44 = IntVar()
        self.namefield44 = Entry(fr4, width=3, textvariable= self.name44)
        self.namefield44.grid(row= 1, column=1, sticky= W)

        self.name45 = IntVar()
        self.namefield45 = Entry(fr4, width=3, textvariable= self.name45)
        self.namefield45.grid(row= 1, column=2, sticky= W)

        self.name46 = IntVar()
        self.namefield46 = Entry(fr4, width=3, textvariable= self.name46)
        self.namefield46.grid(row= 1, column=3, sticky= W)

        self.name47 = IntVar()
        self.namefield47 = Entry(fr4, width=3, textvariable= self.name47)
        self.namefield47.grid(row= 2, column=1, sticky= W)

        self.name48 = IntVar()
        self.namefield48 = Entry(fr4, width=3, textvariable= self.name48)
        self.namefield48.grid(row= 2, column=2, sticky= W)

        self.name49 = IntVar()
        self.namefield49 = Entry(fr4, width=3, textvariable= self.name49)
        self.namefield49.grid(row= 2, column=3, sticky= W)


        fr5 = LabelFrame(fr)
        fr5.grid(row=1, column=1, padx=1, pady=1, sticky=W)

        self.name51 = IntVar()
        self.namefield51 = Entry(fr5, width=3, textvariable= self.name51)
        self.namefield51.grid(row= 0, column=1, sticky= W)

        self.name52 = IntVar()
        self.namefield52 = Entry(fr5, width=3, textvariable= self.name52)
        self.namefield52.grid(row= 0, column=2, sticky= W)

        self.name53 = IntVar()
        self.namefield53 = Entry(fr5, width=3, textvariable= self.name53)
        self.namefield53.grid(row= 0, column=3, sticky= W)

        self.name54 = IntVar()
        self.namefield54 = Entry(fr5, width=3, textvariable= self.name54)
        self.namefield54.grid(row= 1, column=1, sticky= W)

        self.name55 = IntVar()
        self.namefield55 = Entry(fr5, width=3, textvariable= self.name55)
        self.namefield55.grid(row= 1, column=2, sticky= W)

        self.name56 = IntVar()
        self.namefield56 = Entry(fr5, width=3, textvariable= self.name56)
        self.namefield56.grid(row= 1, column=3, sticky= W)

        self.name57 = IntVar()
        self.namefield57 = Entry(fr5, width=3, textvariable= self.name57)
        self.namefield57.grid(row= 2, column=1, sticky= W)

        self.name58 = IntVar()
        self.namefield58 = Entry(fr5, width=3, textvariable= self.name58)
        self.namefield58.grid(row= 2, column=2, sticky= W)

        self.name59 = IntVar()
        self.namefield59 = Entry(fr5, width=3, textvariable= self.name59)
        self.namefield59.grid(row= 2, column=3, sticky= W)


        fr6 = LabelFrame(fr)
        fr6.grid(row=1, column=2, padx=1, pady=1, sticky=W)

        self.name61 = IntVar()
        self.namefield61 = Entry(fr6, width=3, textvariable= self.name61)
        self.namefield61.grid(row= 0, column=1, sticky= W)

        self.name62 = IntVar()
        self.namefield62 = Entry(fr6, width=3, textvariable= self.name62)
        self.namefield62.grid(row= 0, column=2, sticky= W)

        self.name63 = IntVar()
        self.namefield63 = Entry(fr6, width=3, textvariable= self.name63)
        self.namefield63.grid(row= 0, column=3, sticky= W)

        self.name64 = IntVar()
        self.namefield64 = Entry(fr6, width=3, textvariable= self.name64)
        self.namefield64.grid(row= 1, column=1, sticky= W)

        self.name65 = IntVar()
        self.namefield65 = Entry(fr6, width=3, textvariable= self.name65)
        self.namefield65.grid(row= 1, column=2, sticky= W)

        self.name66 = IntVar()
        self.namefield66 = Entry(fr6, width=3, textvariable= self.name66)
        self.namefield66.grid(row= 1, column=3, sticky= W)

        self.name67 = IntVar()
        self.namefield67 = Entry(fr6, width=3, textvariable= self.name67)
        self.namefield67.grid(row= 2, column=1, sticky= W)

        self.name68 = IntVar()
        self.namefield68 = Entry(fr6, width=3, textvariable= self.name68)
        self.namefield68.grid(row= 2, column=2, sticky= W)

        self.name69 = IntVar()
        self.namefield69 = Entry(fr6, width=3, textvariable= self.name69)
        self.namefield69.grid(row= 2, column=3, sticky= W)


        fr7 = LabelFrame(fr)
        fr7.grid(row=2, column=0, padx=1, pady=1, sticky=W)

        self.name71 = IntVar()
        self.namefield71 = Entry(fr7, width=3, textvariable= self.name71)
        self.namefield71.grid(row= 0, column=1, sticky= W)

        self.name72 = IntVar()
        self.namefield72 = Entry(fr7, width=3, textvariable= self.name72)
        self.namefield72.grid(row= 0, column=2, sticky= W)

        self.name73 = IntVar()
        self.namefield73 = Entry(fr7, width=3, textvariable= self.name73)
        self.namefield73.grid(row= 0, column=3, sticky= W)

        self.name74 = IntVar()
        self.namefield74 = Entry(fr7, width=3, textvariable= self.name74)
        self.namefield74.grid(row= 1, column=1, sticky= W)

        self.name75 = IntVar()
        self.namefield75 = Entry(fr7, width=3, textvariable= self.name75)
        self.namefield75.grid(row= 1, column=2, sticky= W)

        self.name76 = IntVar()
        self.namefield76 = Entry(fr7, width=3, textvariable= self.name76)
        self.namefield76.grid(row= 1, column=3, sticky= W)

        self.name77 = IntVar()
        self.namefield77 = Entry(fr7, width=3, textvariable= self.name77)
        self.namefield77.grid(row= 2, column=1, sticky= W)

        self.name78 = IntVar()
        self.namefield78 = Entry(fr7, width=3, textvariable= self.name78)
        self.namefield78.grid(row= 2, column=2, sticky= W)

        self.name79 = IntVar()
        self.namefield79 = Entry(fr7, width=3, textvariable= self.name79)
        self.namefield79.grid(row= 2, column=3, sticky= W)


        fr8 = LabelFrame(fr)
        fr8.grid(row=2, column=1, padx=1, pady=1, sticky=W)

        self.name81 = IntVar()
        self.namefield81 = Entry(fr8, width=3, textvariable= self.name81)
        self.namefield81.grid(row= 0, column=1, sticky= W)

        self.name82 = IntVar()
        self.namefield82 = Entry(fr8, width=3, textvariable= self.name82)
        self.namefield82.grid(row= 0, column=2, sticky= W)

        self.name83 = IntVar()
        self.namefield83 = Entry(fr8, width=3, textvariable= self.name83)
        self.namefield83.grid(row= 0, column=3, sticky= W)

        self.name84 = IntVar()
        self.namefield84 = Entry(fr8, width=3, textvariable= self.name84)
        self.namefield84.grid(row= 1, column=1, sticky= W)

        self.name85 = IntVar()
        self.namefield85 = Entry(fr8, width=3, textvariable= self.name85)
        self.namefield85.grid(row= 1, column=2, sticky= W)

        self.name86 = IntVar()
        self.namefield86 = Entry(fr8, width=3, textvariable= self.name86)
        self.namefield86.grid(row= 1, column=3, sticky= W)

        self.name87 = IntVar()
        self.namefield87 = Entry(fr8, width=3, textvariable= self.name87)
        self.namefield87.grid(row= 2, column=1, sticky= W)

        self.name88 = IntVar()
        self.namefield88 = Entry(fr8, width=3, textvariable= self.name88)
        self.namefield88.grid(row= 2, column=2, sticky= W)

        self.name89 = IntVar()
        self.namefield89 = Entry(fr8, width=3, textvariable= self.name89)
        self.namefield89.grid(row= 2, column=3, sticky= W)


        fr9 = LabelFrame(fr)
        fr9.grid(row=2, column=2, padx=1, pady=1, sticky=W)

        self.name91 = IntVar()
        self.namefield91 = Entry(fr9, width=3, textvariable= self.name91)
        self.namefield91.grid(row= 0, column=1, sticky= W)

        self.name92 = IntVar()
        self.namefield92 = Entry(fr9, width=3, textvariable= self.name92)
        self.namefield92.grid(row= 0, column=2, sticky= W)

        self.name93 = IntVar()
        self.namefield93 = Entry(fr9, width=3, textvariable= self.name93)
        self.namefield93.grid(row= 0, column=3, sticky= W)

        self.name94 = IntVar()
        self.namefield94 = Entry(fr9, width=3, textvariable= self.name94)
        self.namefield94.grid(row= 1, column=1, sticky= W)

        self.name95 = IntVar()
        self.namefield95 = Entry(fr9, width=3, textvariable= self.name95)
        self.namefield95.grid(row= 1, column=2, sticky= W)

        self.name96 = IntVar()
        self.namefield96 = Entry(fr9, width=3, textvariable= self.name96)
        self.namefield96.grid(row= 1, column=3, sticky= W)

        self.name97 = IntVar()
        self.namefield97 = Entry(fr9, width=3, textvariable= self.name97)
        self.namefield97.grid(row= 2, column=1, sticky= W)

        self.name98 = IntVar()
        self.namefield98 = Entry(fr9, width=3, textvariable= self.name98)
        self.namefield98.grid(row= 2, column=2, sticky= W)

        self.name99 = IntVar()
        self.namefield99 = Entry(fr9, width=3, textvariable= self.name99)
        self.namefield99.grid(row= 2, column=3, sticky= W)


        Button(fr, text='Start', command= self.Start).grid(row=3, column=2, sticky=E)
        Button(fr, text='Quit', command= self.master.destroy).grid(row=3, column=2, sticky=W)

    def Start(self):
        sudoku = [[-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1],
        [-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1],
        [-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1,-1,-1,-1,-1]]

        if int(self.name11.get()) != 0 and int(self.name11.get()) <= 9:
            sudoku[0][0] = int(self.name11.get())
        if int(self.name12.get()) != 0 and int(self.name12.get()) <= 9:
            sudoku[0][1] = int(self.name12.get())
        if int(self.name13.get()) != 0 and int(self.name13.get()) <= 9:
            sudoku[0][2] = int(self.name13.get())
        if int(self.name14.get()) != 0 and int(self.name14.get()) <= 9:
            sudoku[1][0] = int(self.name14.get())
        if int(self.name15.get()) != 0 and int(self.name15.get()) <= 9:
            sudoku[1][1] = int(self.name15.get())
        if int(self.name16.get()) != 0 and int(self.name16.get()) <= 9:
            sudoku[1][2] = int(self.name16.get())
        if int(self.name17.get()) != 0 and int(self.name17.get()) <= 9:
            sudoku[2][0] = int(self.name17.get())
        if int(self.name18.get()) != 0 and int(self.name18.get()) <= 9:
            sudoku[2][1] = int(self.name18.get())
        if int(self.name19.get()) != 0 and int(self.name19.get()) <= 9:
            sudoku[2][2] = int(self.name19.get())

        if int(self.name21.get()) != 0 and int(self.name21.get()) <= 9:
            sudoku[0][3] = int(self.name21.get())
        if int(self.name22.get()) != 0 and int(self.name22.get()) <= 9:
            sudoku[0][4] = int(self.name22.get())
        if int(self.name23.get()) != 0 and int(self.name23.get()) <= 9:
            sudoku[0][5] = int(self.name23.get())
        if int(self.name24.get()) != 0 and int(self.name24.get()) <= 9:
            sudoku[1][3] = int(self.name24.get())
        if int(self.name25.get()) != 0 and int(self.name25.get()) <= 9:
            sudoku[1][4] = int(self.name25.get())
        if int(self.name26.get()) != 0 and int(self.name26.get()) <= 9:
            sudoku[1][5] = int(self.name26.get())
        if int(self.name27.get()) != 0 and int(self.name27.get()) <= 9:
            sudoku[2][3] = int(self.name27.get())
        if int(self.name28.get()) != 0 and int(self.name28.get()) <= 9:
            sudoku[2][4] = int(self.name28.get())
        if int(self.name29.get()) != 0 and int(self.name29.get()) <= 9:
            sudoku[2][5] = int(self.name29.get())

        if int(self.name31.get()) != 0 and int(self.name31.get()) <= 9:
            sudoku[0][6] = int(self.name31.get())
        if int(self.name32.get()) != 0 and int(self.name32.get()) <= 9:
            sudoku[0][7] = int(self.name32.get())
        if int(self.name33.get()) != 0 and int(self.name33.get()) <= 9:
            sudoku[0][8] = int(self.name33.get())
        if int(self.name34.get()) != 0 and int(self.name34.get()) <= 9:
            sudoku[1][6] = int(self.name34.get())
        if int(self.name35.get()) != 0 and int(self.name35.get()) <= 9:
            sudoku[1][7] = int(self.name35.get())
        if int(self.name36.get()) != 0 and int(self.name36.get()) <= 9:
            sudoku[1][8] = int(self.name36.get())
        if int(self.name37.get()) != 0 and int(self.name37.get()) <= 9:
            sudoku[2][6] = int(self.name37.get())
        if int(self.name38.get()) != 0 and int(self.name38.get()) <= 9:
            sudoku[2][7] = int(self.name38.get())
        if int(self.name39.get()) != 0 and int(self.name39.get()) <= 9:
            sudoku[2][8] = int(self.name39.get())

        if int(self.name41.get()) != 0 and int(self.name41.get()) <= 9:
            sudoku[3][0] = int(self.name41.get())
        if int(self.name42.get()) != 0 and int(self.name42.get()) <= 9:
            sudoku[3][1] = int(self.name42.get())
        if int(self.name43.get()) != 0 and int(self.name43.get()) <= 9:
            sudoku[3][2] = int(self.name43.get())
        if int(self.name44.get()) != 0 and int(self.name44.get()) <= 9:
            sudoku[4][0] = int(self.name44.get())
        if int(self.name45.get()) != 0 and int(self.name45.get()) <= 9:
            sudoku[4][1] = int(self.name45.get())
        if int(self.name46.get()) != 0 and int(self.name46.get()) <= 9:
            sudoku[4][2] = int(self.name46.get())
        if int(self.name47.get()) != 0 and int(self.name47.get()) <= 9:
            sudoku[5][0] = int(self.name47.get())
        if int(self.name48.get()) != 0 and int(self.name48.get()) <= 9:
            sudoku[5][1] = int(self.name48.get())
        if int(self.name49.get()) != 0 and int(self.name49.get()) <= 9:
            sudoku[5][2] = int(self.name49.get())

        if int(self.name51.get()) != 0 and int(self.name51.get()) <= 9:
            sudoku[3][3] = int(self.name51.get())
        if int(self.name52.get()) != 0 and int(self.name52.get()) <= 9:
            sudoku[3][4] = int(self.name52.get())
        if int(self.name53.get()) != 0 and int(self.name53.get()) <= 9:
            sudoku[3][5] = int(self.name53.get())
        if int(self.name54.get()) != 0 and int(self.name54.get()) <= 9:
            sudoku[4][3] = int(self.name54.get())
        if int(self.name55.get()) != 0 and int(self.name55.get()) <= 9:
            sudoku[4][4] = int(self.name55.get())
        if int(self.name56.get()) != 0 and int(self.name56.get()) <= 9:
            sudoku[4][5] = int(self.name56.get())
        if int(self.name57.get()) != 0 and int(self.name57.get()) <= 9:
            sudoku[5][3] = int(self.name57.get())
        if int(self.name58.get()) != 0 and int(self.name58.get()) <= 9:
            sudoku[5][4] = int(self.name58.get())
        if int(self.name59.get()) != 0 and int(self.name59.get()) <= 9:
            sudoku[5][5] = int(self.name59.get())

        if int(self.name61.get()) != 0 and int(self.name61.get()) <= 9:
            sudoku[3][6] = int(self.name61.get())
        if int(self.name62.get()) != 0 and int(self.name62.get()) <= 9:
            sudoku[3][7] = int(self.name62.get())
        if int(self.name63.get()) != 0 and int(self.name63.get()) <= 9:
            sudoku[3][8] = int(self.name63.get())
        if int(self.name64.get()) != 0 and int(self.name64.get()) <= 9:
            sudoku[4][6] = int(self.name64.get())
        if int(self.name65.get()) != 0 and int(self.name65.get()) <= 9:
            sudoku[4][7] = int(self.name65.get())
        if int(self.name66.get()) != 0 and int(self.name66.get()) <= 9:
            sudoku[4][8] = int(self.name66.get())
        if int(self.name67.get()) != 0 and int(self.name67.get()) <= 9:
            sudoku[5][6] = int(self.name67.get())
        if int(self.name68.get()) != 0 and int(self.name68.get()) <= 9:
            sudoku[5][7] = int(self.name68.get())
        if int(self.name69.get()) != 0 and int(self.name69.get()) <= 9:
            sudoku[5][8] = int(self.name69.get())

        if int(self.name71.get()) != 0 and int(self.name71.get()) <= 9:
            sudoku[6][0] = int(self.name71.get())
        if int(self.name72.get()) != 0 and int(self.name72.get()) <= 9:
            sudoku[6][1] = int(self.name72.get())
        if int(self.name73.get()) != 0 and int(self.name73.get()) <= 9:
            sudoku[6][2] = int(self.name73.get())
        if int(self.name74.get()) != 0 and int(self.name74.get()) <= 9:
            sudoku[7][0] = int(self.name74.get())
        if int(self.name75.get()) != 0 and int(self.name75.get()) <= 9:
            sudoku[7][1] = int(self.name75.get())
        if int(self.name76.get()) != 0 and int(self.name76.get()) <= 9:
            sudoku[7][2] = int(self.name76.get())
        if int(self.name77.get()) != 0 and int(self.name77.get()) <= 9:
            sudoku[8][0] = int(self.name77.get())
        if int(self.name78.get()) != 0 and int(self.name78.get()) <= 9:
            sudoku[8][1] = int(self.name78.get())
        if int(self.name79.get()) != 0 and int(self.name79.get()) <= 9:
            sudoku[8][2] = int(self.name79.get())

        if int(self.name81.get()) != 0 and int(self.name81.get()) <= 9:
            sudoku[6][3] = int(self.name81.get())
        if int(self.name82.get()) != 0 and int(self.name82.get()) <= 9:
            sudoku[6][4] = int(self.name82.get())
        if int(self.name83.get()) != 0 and int(self.name83.get()) <= 9:
            sudoku[6][5] = int(self.name83.get())
        if int(self.name84.get()) != 0 and int(self.name84.get()) <= 9:
            sudoku[7][3] = int(self.name84.get())
        if int(self.name85.get()) != 0 and int(self.name85.get())<= 9:
            sudoku[7][4] = int(self.name85.get())
        if int(self.name86.get()) != 0 and int(self.name86.get()) <= 9:
            sudoku[7][5] = int(self.name86.get())
        if int(self.name87.get()) != 0 and int(self.name87.get()) <= 9:
            sudoku[8][3] = int(self.name87.get())
        if int(self.name88.get()) != 0 and int(self.name88.get()) <= 9:
            sudoku[8][4] = int(self.name88.get())
        if int(self.name89.get()) != 0 and int(self.name89.get()) <= 9:
            sudoku[8][5] = int(self.name89.get())

        if int(self.name91.get()) != 0 and int(self.name91.get()) <= 9:
            sudoku[6][6] = int(self.name91.get())
        if int(self.name92.get()) != 0 and int(self.name92.get()) <= 9:
            sudoku[6][7] = int(self.name92.get())
        if int(self.name93.get()) != 0 and int(self.name93.get()) <= 9:
            sudoku[6][8] = int(self.name93.get())
        if int(self.name94.get()) != 0 and int(self.name94.get()) <= 9:
            sudoku[7][6] = int(self.name94.get())
        if int(self.name95.get()) != 0 and int(self.name95.get()) <= 9:
            sudoku[7][7] = int(self.name95.get())
        if int(self.name96.get()) != 0 and int(self.name96.get()) <= 9:
            sudoku[7][8] = int(self.name96.get())
        if int(self.name97.get()) != 0 and int(self.name97.get()) <= 9:
            sudoku[8][6] = int(self.name97.get())
        if int(self.name98.get()) != 0 and int(self.name98.get()) <= 9:
            sudoku[8][7] = int(self.name98.get())
        if int(self.name99.get()) != 0 and int(self.name99.get()) <= 9:
            sudoku[8][8] = int(self.name99.get())

        for i in range(0,9):
            for j in range(0,9):
                if sudoku[i][j] == -1:
                    sudoku[i][j] = 0

        self.SolveIt(sudoku)

    def SolveIt(self, sudoku):            
        yeet = AlgoSolve.Main(sudoku)
        return yeet

    def Display(self, grid):
        for Row in range(0,9):
            for Column in range(0,9):
                if grid[Row][Column] == -1:
                    grid[Row][Column] = " "
                print(grid[Row][Column], end=' | ')
            print('{0:>3}'.format(Row))
        print()
4

0 回答 0