Field noteTR1 min read

Kivy Course #4 – Box Layout Example

Arşiv notu: Bu yazı özgün haliyle korunmuştur. Sürümler, bağlantılar veya komutlar güncelliğini yitirmiş olabilir.

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.

Python file

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()

Kivy language file

<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.