popup: include popup in the showcase

This commit is contained in:
Mathieu Virbel 2011-06-06 16:40:03 +02:00
parent e6239470b1
commit 9ca6e317ec
2 changed files with 23 additions and 4 deletions

View File

@ -13,6 +13,8 @@ from kivy.uix.scatter import Scatter
from kivy.uix.textinput import TextInput
from kivy.uix.treeview import TreeView, TreeViewLabel
from kivy.uix.switch import Switch
from kivy.uix.label import Label
from kivy.uix.popup import Popup
class Showcase(FloatLayout):
@ -69,8 +71,9 @@ class ShowcaseApp(App):
n = create_tree('TreeView')
attach_node('Standard treeview', n)
attach_node('Treeview without root', n)
n = create_tree('Switch')
attach_node('Active switch', n)
n = create_tree('Others')
attach_node('Popup', n)
attach_node('Switch', n)
root.add_widget(tree)
self.content = content = BoxLayout()
root.add_widget(content)
@ -127,11 +130,28 @@ class ShowcaseApp(App):
multiline=False))
return col
def show_active_switch(self):
def show_switch(self):
col = AnchorLayout()
col.add_widget(Switch(active=True))
return col
def show_popup(self):
btnclose = Button(text='Close this popup', size_hint_y=None, height=50)
content = BoxLayout(orientation='vertical')
content.add_widget(Label(text='Hello world'))
content.add_widget(btnclose)
popup = Popup(content=content, title='Modal popup example',
size_hint=(None, None), size=(300, 300),
auto_dismiss=False)
btnclose.bind(on_release=popup.dismiss)
button = Button(text='Open popup', size_hint=(None, None),
size=(150, 70))
button.bind(on_release=popup.open)
popup.open()
col = AnchorLayout()
col.add_widget(button)
return col
def show_standard_treeview(self):
return self.populate_treeview(TreeView())

View File

@ -187,7 +187,6 @@ class Popup(FloatLayout):
return True
def on__anim_alpha(self, instance, value):
print value
if value == 0 and self._window is not None:
self._window.remove_widget(self)
self._window = None