Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.uix.dropdown import DropDown
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.properties import NumericProperty
- from kivy.animation import Animation
- KV = '''
- FloatLayout:
- Spinner:
- dropdown_cls: 'SlowDown'
- text: 'sing along'
- values: 'hello darkness my old friend'.split(' ')
- size_hint: None, None
- size: 100, 38
- pos_hint: {'center': (.5, .5)}
- '''
- class SlowDown(DropDown):
- item_delay = NumericProperty(.1)
- display_time = NumericProperty(.5)
- def open(self, widget):
- super(SlowDown, self).open(widget)
- # determine if we openned up or down
- if self.attach_to.y > self.y:
- children = reversed(self.container.children)
- else:
- children = self.container.children
- #
- for i, w in enumerate(children):
- anim = (
- Animation(duration=i * self.item_delay)
- + Animation(opacity=1, duration=self.display_time)
- )
- w.opacity = 0
- anim.start(w)
- bar_color = self.bar_color
- def restore_bar_color(*args):
- Animation(bar_color=bar_color, d=self.display_time).start(self)
- self.bar_color = (0, 0, 0, 0)
- anim.bind(on_complete=restore_bar_color)
- class SlowDownApp(App):
- def build(self):
- return Builder.load_string(KV)
- if __name__ == '__main__':
- SlowDownApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement