Kivy Course #4 – Box Layout Example

This part is continuing with BoxLayout class of Kivy. BoxLayout is another common layout which is used frequently. It supports both vertical and horizontal orientations and size hints to spare the widgets at specific ratios.

The Python code is:

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout

class RootWidget(BoxLayout):
    pass

class kutuApp(App):
    def build(self):
        return RootWidget()


if __name__ == "__main__":
    kutuApp().run()

And the Kivy Language file is:

<RootWidget>:
    orientation: "vertical"
    BoxLayout:
        size_hint_y: 0.2
        Button:
            text: "bir"
            size_hint_x: 0.2
        Button:
            text: "iki"
    BoxLayout:
        size_hint_y: 0.3
        Button:
            text: "üç"
            size_hint_x: 0.6
        Button:
            text: "dört"
        Widget:
    GridLayout:
        cols: 2
        rows: 2
        Button:
            text: "S1 S1"
        Button:
            text: "S1 S2"
        Button:
            text: "S2 S1"
        Button:
            text: "S2 S2"

More explained documentation will come soon.

 
comments powered by Disqus