Created
May 6, 2019 01:05
-
-
Save Dirk-Sandberg/72b4309e9e4e6cb55d9c6385b48b0037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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