showcase: add scatter examples

This commit is contained in:
Mathieu Virbel 2011-04-22 00:52:55 +02:00
parent cd5237128a
commit 19d7ad7521
2 changed files with 41 additions and 0 deletions

View File

@ -8,12 +8,20 @@ from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.button import Button
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.slider import Slider
from kivy.uix.widget import Widget
from kivy.uix.scatter import Scatter
from kivy.uix.textinput import TextInput
from kivy.uix.treeview import TreeView, TreeViewLabel
class Showcase(FloatLayout):
pass
class KivyImageScatter(Scatter):
pass
class ButtonsScatter(Scatter):
pass
class ShowcaseApp(App):
def on_select_node(self, instance, value):
@ -44,6 +52,9 @@ class ShowcaseApp(App):
n = create_tree('Sliders')
attach_node('Horizontal sliders', n)
attach_node('Vertical sliders', n)
n = create_tree('Scatter')
attach_node('Scatter with image', n)
attach_node('Scatter with buttons', n)
n = create_tree('Textinput')
attach_node('Monoline textinput', n)
attach_node('Multiline textinput', n)
@ -57,6 +68,19 @@ class ShowcaseApp(App):
sc.content.add_widget(root)
return sc
def show_scatter_with_image(self):
s = KivyImageScatter(center=self.content.center)
col = Widget()
col.add_widget(s)
return col
def show_scatter_with_buttons(self):
s = ButtonsScatter(size=(300, 200))
s.center = self.content.center
col = Widget()
col.add_widget(s)
return col
def show_standard_buttons(self):
col = BoxLayout(spacing=10)
col.add_widget(Button(text='Hello world'))

View File

@ -32,3 +32,20 @@
FloatLayout:
id: content
<KivyImageScatter>:
Image:
source: 'data/logo/kivy-icon-512.png'
<ButtonsScatter>:
canvas:
Color:
rgba: .5, .5, .5, .5
Rectangle:
size: self.size
BoxLayout:
size: root.size
padding: 40
Button:
text: 'Hello'
Button:
text: 'World'