Field noteEN1 min read
Kivy Course #3 – Grid Layout Example
Archive note: This article is preserved in its original form. Versions, links or commands may now be outdated.
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.
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()
Kivy language file (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"