Skip to content

Instantly share code, notes, and snippets.

@Cheaterman
Created November 12, 2014 07:01
Show Gist options
  • Save Cheaterman/9f310da533d841a19fc2 to your computer and use it in GitHub Desktop.
Save Cheaterman/9f310da533d841a19fc2 to your computer and use it in GitHub Desktop.
Simple KV loop
__author__ = 'Cheaterman'
from functools import partial
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.lang import Builder
kv = """
#:import Button kivy.uix.button.Button
<TestWidget>:
GridLayout:
pos: 100, 100
size: 100, 100
cols: 3
rows: 3
on_parent:
if not self.children: \
[self.add_widget(Button(text=str(i))) for i in range(1, 10)]
"""
Builder.load_string(kv)
class TestWidget(Widget):
pass
class TestApp(App):
def build(self):
return TestWidget()
if __name__ == '__main__':
TestApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment