wxPython not getting the corret widgets in grid

Hello, I’m doing an school project in python. I’m trying to get the widgets in a grid cell, here is an image with the current window and the hierarchy.

Before I only had a button in each cell and I used this code to get the button:

children = self.gGrid.GetChildren()
        for i in children:
            button = i.Window

But now I have in each cell a sizer and inside that sizer I have a label and a button and if I execute this code above I get None as a result. So I printed the i var and i got as a result this wx._core.SizerItem and it don’t have children attribute. To note that the widgets are created dynamicly I just posted the hierarchy to help understand what I’m trying to do.
Does anyone know how I can have the button and the label please? Maybe I’m doing something wrong? Is there another best way to do what I’m trying to do?
Thanks so much for the help.

You can easily maintain your own list(s) of the buttons and/or other widgets if you need access to them later. Then the structure of the sizer layout doesn’t matter.

    btn = wx.Button(self, ...)
    sizer.Add(btn, ...)
    self.my_buttons.append(btn)
...
    for btn in self.my_buttons:
        do_something(button)

Or you can fetch the buttons in other ways without keeping track of them in your own list. For example, if you keep track of the IDs given to the buttons then you can do this:

    button = self.FindWindow(some_ID)

FindWindow can also be used to find children by name, if you give the buttons unique names.

You can also iterate through all children of self and find the buttons that way, like this:

    for obj in self.GetChildren():
        if isinstance(obj, wx.Button):
            do_something(obj)

Hello Ronbin, thank you so much for your reaply, that is a nice way to do what I need.