Last active
May 10, 2019 12:50
-
-
Save el3/a6b6344dba2cf0a1feb9338f17aedf48 to your computer and use it in GitHub Desktop.
boxlayout_animation
This file contains hidden or 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.lang import Builder | |
from kivy.app import App | |
from kivy.animation import Animation | |
class MyAnim(Animation): | |
def on_complete(self, widget): | |
widget.expanded = not widget.expanded | |
if not widget.expanded: | |
widget.size_hint = (1,1) | |
KV = """ | |
<MyButton@Button>: | |
font_size: "30sp" | |
expanded: False | |
on_release: | |
self.size_hint = (None, 1) | |
anim = app.anim(width=self.parent.width/3 if self.expanded else self.parent.width) | |
anim.start(self) | |
BoxLayout: | |
MyButton: | |
text: "test1" if self.width > 10 else "" | |
MyButton: | |
text: "test2" if self.width > 10 else "" | |
MyButton: | |
text: "test3" if self.width > 10 else "" | |
""" | |
class MyApp(App): | |
anim = MyAnim | |
def build(self): | |
return Builder.load_string(KV) | |
MyApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment