예제 #1
0
    def build(self):
        self.title = 'Sudoku Solver'
        Window.size = (1400, 800)
        Window.top = 50
        Window.left = 50

        layout = MyGridLayout(level=1, rows=4, cols=3, rowsAndCols={})

        #Window.clearcolor = black
        for rowA in range(3):
            for colA in range(3):
                innerLayout1 = MyGridLayout(rows=3, cols=3, level=2, rowsAndCols={'rowA':rowA, 'colA':colA})
                layout.add_widget(innerLayout1)
                for rowB in range(3):
                    for colB in range(3):
                        innerLayout2 = MyGridLayout(rows=3, cols=3, level=3, rowsAndCols={'rowA':rowA, 'colA':colA, 'rowB':rowB, 'colB':colB})
                        innerLayout1.add_widget(innerLayout2)
                        for rowC in range(3):
                            for colC in range(3):
                                cell = Cell({'rowA':rowA, 'colA':colA, 'rowB':rowB, 'colB':colB, 'rowC':rowC, 'colC':colC})
                                cell.setText()
                                innerLayout2.add_widget(cell)
        layout.background_normal = ''
        layout.background_color = red
        Window.bind(mouse_pos=MyGridLayout.mouseOverGrid)
        Window.bind(on_key_down=MyGridLayout.enterNumberInCell)
        global initialCells
        Clock.schedule_once(partial(self.populate, initialCells), 1.0)
        
        timer = Button(text="0:00")
        timer.size_hint = (1, 0.1)
        timer.color = red
        timer.time = 0
        timer.active = True
        timer.bind(on_press=self.stopTimer)
        layout.add_widget(timer)
        self.timer = timer
        return layout