Kivy Course #3 – Grid Layout Example

In this section, layouts are introduced with more details and images of them are shown. Grid layout is one of the most known widgets and the code may be found below.

The main Python file:

from kivy.app import App
from kivy.uix.gridlayout import GridLayout

class RootWidget(GridLayout):
    pass

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


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

And the Kivy Language file which should be named as izgara.kv:

<RootWidget>:
    cols: 3
    rows: 2
    Button:
        text: "S1 S1"
        size_hint_x: None
        width: 300
    Button:
        text: "S1 S2"
    Button:
        text: "S1 S3"
    Button:
        text: "S2 S1"
        size_hint_x: None
        width: 300
    Button:
        text: "S2 S2"
    Button:
        text: "S2 S3"

 

 
comments powered by Disqus