Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Cyclic animations
-
I'd like to build an interface like that in pythonista's UI builder to allow modification of the "flex" attribute. It will be a custom view, like my chordcalc interfaces for the "arrows". More, specifically, I want the same sort of visual queue as @OMZ has included (morphing from before shape/position to after and back again) as you change the settings.
I guess use
ui.animate()
along with aui.delay()
to fire aset_needs_display()
timed to come after the animation time. Other thoughts before I waste a lot of time going over well trodden paths are appreciated. -
animate
has acompletion
argument, which gets called when the animation completes.
This lets you string together animations. In that way, you don't need to call delay orset_needs_display
.Here's an example updated from an old thread (before I knew about
completion
).import time import ui, console root=ui.View(frame=(0,0,500,500)) somecontainer=ui.View(frame=(50,5,200,200),bg_color=(1,0,0)) root.add_subview(somecontainer) b=ui.Button(bg_color=(0,1,0),frame=(50,50,100,100)) somecontainer.add_subview(b) b.action=lambda sender:console.hud_alert('yes, i am a button') def demo(flex): #show the flex mode of b by resizing its parent view, first big, then small. b.flex=flex b.title="b.flex='{}'".format(b.flex) duration=1.0 #animation speed def small(): somecontainer.frame=(50,50,200,200) def big(): somecontainer.frame=(50,50,400,400) def animation_small(): #completion could call animation_big again, as long as you have a stopping condition! ui.animate(small, duration=duration) def animation_big(): #animate to big size, then call animation_small ui.animate(big, duration=duration,completion=animation_small) animation_big() root.present('sheet') for x in ['','lrtb','l','t','w','h','wh','wl','ht']: demo(x) time.sleep(3.0)
-
Marvelous. Where do you find these things!!? Are you secretly plying OMZ with Red Bull?
-
Yes, this is cool. Just watching the animation if you are a newbie like me can really help get flex in your head. Ok, there is an animation in the ui designer, but this sends the message home somehow. Also can see the code of course. Thanks