#:import random random.random

ShowcaseScreen:
    name: 'TabbedPanel + Layouts'
    fullscreen: True
    on_parent: if args[1] and tp.current_tab == tab_fl: app.showcase_floatlayout(fl)

    TabbedPanel:
        id: tp
        do_default_tab: False

        TabbedPanelItem:
            id: tab_fl
            text: 'FloatLayout'
            on_release: app.showcase_floatlayout(fl)
            FloatLayout:
                CFloatLayout:
                    id: fl
        TabbedPanelItem:
            text: 'BoxLayout'
            on_release: app.showcase_boxlayout(box)
            FloatLayout
                CBoxLayout:
                    id: box
        TabbedPanelItem:
            text: 'GridLayout'
            on_release: app.showcase_gridlayout(grid)
            FloatLayout
                CGridLayout:
                    id: grid
                    rows: 3
        TabbedPanelItem:
            on_release: app.showcase_stacklayout(stack)
            text: 'StackLayout'
            FloatLayout
                CStackLayout:
                    id: stack
        TabbedPanelItem:
            text: 'AnchorLayout'
            on_release: app.showcase_anchorlayout(anchor)
            FloatLayout
                CAnchorLayout:
                    id: anchor
                    BoxLayout:
                        orientation: 'vertical'
                        size_hint: .4, .5
                        Button
                        Button
                            text: 'anchor_x: {}'.format(anchor.anchor_x)
                        Button
                            text: 'anchor_y: {}'.format(anchor.anchor_y)
                        Button

<CFloatLayout@FloatLayout+BackgroundColor>
<CBoxLayout@BoxLayout+BackgroundColor>
<CGridLayout@GridLayout+BackgroundColor>
<CStackLayout@StackLayout+BackgroundColor>
<CAnchorLayout@AnchorLayout+BackgroundColor>


<BackgroundColor@Widget>
    pos_hint: {'center_x': .5, 'center_y': .5}
    size_hint: .9, .9
    canvas.before:
        Color:
            rgba: .2, .3, .4, 1
        Rectangle:
            size: self.size
            pos: self.pos
