Search code examples
pythonpython-3.xkivykivy-language

Get the type (Label, Button, etc.) of a kivy widget in python


Is there any way to get the type of a kivy widget in python?

By type I refer to things like Label, Button, TextInput etc.

something like my_widget.type which e.g. allows me to put all TextInputs into one list.


Solution

  • If you have a normal reference to a Widget, you can use:

    type(widget)
    

    But if you have a WeakProxy (like the ids dictionary uses), then you need to do:

    type(self.ids.widget.__self__)