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.
ui.animate for nested class functions is really awkward
-
Say I have a class, in which I have the function
animate(self)
which does a bunch of actions and then animates something. It looks somehing like this:def animate(self): def anim(self): self.subviews[0].frame=(10, 10, 100, 120) #Do stuff here ui.animate(anim(self), 1)
This doesn't work, because then it's not callable. Additionally, using
self.anim
doesn't work, because anim isn't in the main namespace of the class. I actually have to callui.animate(lambda: anim(self), 1)
This seems awkward... Am I missing something?
-
Wait... Answered my own question.
anim
doesn't needself
as an argument, because it inherits this from the parent's namespace. I can usedef animate(self): def anim(): self.subviews[0].frame=(10, 10, 100, 120) #Do stuff here ui.animate(anim, 1)