Skip to content

Instantly share code, notes, and snippets.

@Dirk-Sandberg
Created May 6, 2019 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dirk-Sandberg/72b4309e9e4e6cb55d9c6385b48b0037 to your computer and use it in GitHub Desktop.
Save Dirk-Sandberg/72b4309e9e4e6cb55d9c6385b48b0037 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.animation import Animation
# Makes a widget bounce around the screen
kv = """
<AnimatedMenu@GridLayout>:
cols: 2
spacing: 10,
padding: 10,
canvas.before:
Color:
rgb: 1,1,1
Rectangle:
size: self.size
pos: self.pos
Button:
text: "NO"
Button:
text: "YES"
FloatLayout:
AnimatedMenu:
id: animated_widget
size_hint: .5, .2
top_hint: 1
right_hint: 1
pos_hint: {"top": self.top_hint, "right": self.right_hint}
"""
kv = Builder.load_string(kv)
class MainApp(App):
def build(self):
return kv
def on_start(self):
Clock.schedule_interval(self.animate, 5)
def animate(self, *args):
anim = Animation(top_hint=0.2, transition='in_out_bounce')
anim += Animation(right_hint=0.5, transition='in_bounce')
anim += Animation(top_hint=1, transition='out_bounce')
anim += Animation(right_hint=1, transition='in_out_circ')
anim.start(self.root.ids.animated_widget)
MainApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment