Search code examples
python-3.xkivy-language

Kivy Language Indentation Rules


I'm trying to get my head around one of the kivy-examples, the showcase one.

I have a basic understandig of the Kivy language rules but I don't know how to explain this kind of indentation:

<ShowcaseScreen>:
    ScrollView:
        AnchorLayout:
            GridLayout:
BoxLayout:
    ActionBar:
    ScrollView:
    ScreenManager:

To be more specific, why the ShowcaseScreen class starts with an indented ScrollView widget and then the BoxLayout is not indented? Based on what I see, the BoxLayout is on top of the ScrollView widget, which is somehow unexpected since the BoxLayout is the root widget...can someone clarify?

thanks


Solution

  • Take a look here https://kivy.org/docs/guide/lang.html#rule-context

    BoxLayout is the root widget, whereas ShowcaseScreen is a class rule due to <>. They are not linked to each other, but you could put ShowcaseScreen below ScreenManager again indented.