2015-01-26 15:05:55 +00:00
|
|
|
'''
|
2015-01-26 15:17:23 +00:00
|
|
|
Demonstrates using kv language to create some simple buttons and a
|
2015-01-23 22:44:45 +00:00
|
|
|
label, with each button modifying the label text.
|
|
|
|
'''
|
|
|
|
|
|
|
|
from kivy.app import App
|
|
|
|
from kivy.uix.boxlayout import BoxLayout
|
|
|
|
from kivy.lang import Builder
|
|
|
|
|
|
|
|
Builder.load_string('''
|
|
|
|
<MainWidget>:
|
|
|
|
BoxLayout:
|
|
|
|
orientation: 'vertical'
|
|
|
|
Button:
|
|
|
|
text: 'some string '
|
|
|
|
on_press: the_right_pane.text += self.text
|
|
|
|
Button:
|
|
|
|
text: 'one two three four '
|
|
|
|
on_press: the_right_pane.text += self.text
|
|
|
|
Button:
|
|
|
|
text: 'follow the yellow brick road '
|
|
|
|
on_press: the_right_pane.text += self.text
|
|
|
|
Button:
|
|
|
|
text: 'five six seven eight '
|
|
|
|
on_press: the_right_pane.text += self.text
|
|
|
|
Button:
|
|
|
|
text: 'CLEAR LABEL'
|
|
|
|
on_press: the_right_pane.text = ''
|
|
|
|
Label:
|
|
|
|
id: the_right_pane
|
|
|
|
text: ''
|
|
|
|
text_size: self.size
|
|
|
|
halign: 'center'
|
|
|
|
valign: 'middle'
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
|
class MainWidget(BoxLayout):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ExampleApp(App):
|
|
|
|
def build(self):
|
|
|
|
return MainWidget()
|
|
|
|
|
|
|
|
ExampleApp().run()
|
|
|
|
|