Empty list of ids in a Kivy GridLayout
<p>I am trying to develop a toy app with Kivy.</p>

<p>So far I have a grid of 9 x 9 <code>TextInput</code> widgets that have been added programmatically to a <code>GridLayout</code> (I refer to it by the id "grid" in my kv file).</p>

<p>For some reason, although I am assigning an id to each of the <code>TextInput</code> widgets, the ids dictionary that I get in <code>the get_widget_from_id</code> is empty.</p>

<p>What am I missing? </p>

<p><strong>main.py</strong></p>

<pre><code>from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.textinput import TextInput
from kivy.clock import Clock

class SudokuGame(Widget):
    # Initialize the grid of text inputs
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        grid = self.ids["grid"]
        for i in range(81):
            row = i // 9
            col = i  % 9
            grid.add_widget(TextInput(id = str(row) + "-" + str(col)))

    # Try to retrieve one of the widgets from its id
    def get_widget_from_id(self, *args):
        print(self.ids["grid"].ids)

class SudokuApp(App):
    def build(self):
        game = SudokuGame()
        Clock.schedule_once(game.get_widget_from_id)
        return game

if __name__ == '__main__':
    SudokuApp().run()
</code></pre>

<p><strong>sudoku.kv</strong></p>

<pre><code>#:kivy 1.9.1

&lt;TextInput@SudokuGame&gt;:
    text: ""
    font_size: 0.7 * self.width
    padding: 0.3 * self.width, (self.height - self.line_height) / 2
    input_filter: lambda text, from_undo: text if ( 0 &lt; int(text) &lt; 10 and len(self.text) == 0 ) else ""
    multiline: False
    cursor_color: [0, 0, 0, 0]

&lt;SudokuGame&gt;:
    canvas.before:
        Color:
            rgb: 1, 1, 1
        Rectangle:
            pos: self.pos
            size: self.size
    BoxLayout:
        orientation: "vertical"
        size: root.size
        GridLayout:
            id: grid
            rows: 9
            cols: 9
            line_size: 6
            canvas:
                Color:
                    rgb: 0, 0, 0
                Rectangle:
                    pos: self.x + self.width / 3 - self.line_size / 2, self.y
                    size: self.line_size, self.height
                Rectangle:
                    pos: self.x + 2 * self.width / 3 - self.line_size / 2, self.y
                    size: self.line_size, self.height
                Rectangle:
                    pos: self.x, self.y  + self.height / 3 - self.line_size / 2
                    size: self.width, self.line_size
                Rectangle:
                    pos: self.x, self.y  + 2 * self.height / 3 - self.line_size / 2
                    size: self.width, self.line_size
        BoxLayout:
            orientation: "horizontal"
            size_hint: 1, 0.1
            Button:
                text: "Solve"
            Button:
                text: "Clear"
</code></pre>