2011-04-08 14:38:33 +00:00
|
|
|
from kivy.lang import Builder
|
|
|
|
from kivy.app import App
|
|
|
|
from kivy.uix.boxlayout import BoxLayout
|
|
|
|
|
|
|
|
Builder.load_string('''
|
|
|
|
[BlehItem@BoxLayout]:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Label:
|
|
|
|
text: str(ctx.idx)
|
|
|
|
Button:
|
|
|
|
text: ctx.word
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
|
class BlehApp(App):
|
|
|
|
|
|
|
|
def build(self):
|
|
|
|
root = BoxLayout()
|
|
|
|
for idx, word in enumerate(('Hello', 'World')):
|
2012-11-03 21:18:35 +00:00
|
|
|
wid = Builder.template('BlehItem', **{
|
2011-04-08 14:38:33 +00:00
|
|
|
'idx': idx, 'word': word,
|
|
|
|
})
|
|
|
|
root.add_widget(wid)
|
|
|
|
return root
|
|
|
|
|
2016-12-17 09:41:12 +00:00
|
|
|
|
2011-04-08 14:38:33 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
BlehApp().run()
|