omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Scripter (again)

    Pythonista
    1
    1
    826
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mikael
      mikael last edited by

      I had a need for some animations for this thing I was doing (running a kind of a lottery on the big screen before the Star Wars movie tomorrow), and I used scripter again. I was happy how linear and easily readable it makes stuff, without extra animation functions or callbacks.

      So, wanted to advertise it (again), in case there are new people, or people with new animation needs.

      Part of what I needed to happen was:

      1. Marker is created, big as the screen
      2. It zooms to a specific spot and size
      3. It moves from point to point, stopping for a second at each
      4. It zooms out again to full screen, and simultaneously its:
      5. Round corners get squared
      6. Background darkens to black
      7. New content is presented
      8. After user taps it, it fades away

      And here is the method, with yield marking the places where we wait for previous actions to complete:

      @script
      def run_lottery(self):
          spot = self.create_marker(self)
          self.add_subview(spot)
          width(spot, 15)
          height(spot, 20)
          pos = self.next_position()
          while pos:
              center(spot, pos)
              yield 1.0
              pos = self.next_position()
          frame(spot, self.bounds)
          corner_radius(spot, 0)
          background_color(spot, 'black')
          yield
          self.present_result(spot)
          wait_for_tap(spot)
          yield
          hide(spot)
          yield
          self.remove_subview(spot)
      

      Since last version, I have added the wait_for_tap function, as well as convenience functions like background_color, corresponding to all animatable properties of the ui module views.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB Forums | Contributors