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.


    Fade in and fade out problem

    Pythonista
    3
    4
    2856
    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.
    • Kluesi
      Kluesi last edited by

      Hi

      I use Pythonista in Version 2.1.1 (211008) on my iPhone 6 and I want to fade in and fade out a Label on a UI view. I found many examples but none of them works for me.

      The scenario: The User of my app presses a button and in the background somthing happens. But the user gets no feedback. So I placed a Label on the screen center and after the button press event I want to show the label a secound and hide it.

      I found the animate() function and tried it this way:


      def showInfo(Infotext, aView):
      def doAnimation():
      aView['MyLabel'].alpha=1

      aView['MyLabel'].text='This is my message'
      ui.animate(doAnimation)

      If i call the showInfo function the Label fades in on the screen. This works. But after a second I want to fade out the label. I tried many ways to implement a fade out but none of them works. I tried to define an second function called doAnimation2 with aView['MyLabel'].alpha=0 and called it the same way like doAnimate. I also tried to set the alpha value to 0 after the ui.animate call. But the label dosen't show. No fade in, no fade out. I also serached for a definition of the animate function but I only found a very small doku about this.

      So, please help me.

      1. How can I fade in and after a secound fade out my label in the example above?

      2. What does the ui.animate function do exactly and what are the parameters of this function.

      Many thanks

      kluesi

      mikael 1 Reply Last reply Reply Quote 0
      • enceladus
        enceladus last edited by

        https://github.com/encela95dus/ios_pythonista_examples Contains few animation examples and I hope it helps

        animation examples
        animate1.py - animating color
        animation2.py - animating scale, alpha and move
        transform playground https://forum.omz-software.com/topic/2268/view-transform-origin
        direct replacement for ui.animate with more easing functions and support for chaining several animations to run on sequence
        https://github.com/controversial/ui2/blob/master/ui2/animate.py
        viewslide.py
        delay_test.py
        from forum
        https://forum.omz-software.com/topic/3504/lab-ui-animate-sliding-in-views
        gstate https://forum.omz-software.com/topic/3180/understanding-ui-transform-rotation

        1 Reply Last reply Reply Quote 0
        • mikael
          mikael @Kluesi last edited by

          @Kluesi, Scripter has a ready-made function for fades and quite a few effects besides. Useful if you want to do a lot of these small animations, and often in parallel or in sequence.

          1 Reply Last reply Reply Quote 0
          • Kluesi
            Kluesi last edited by

            Thanks for the answers. Now I know what is wrong. I didn't mentioned that animated() ist a kind of separate thread and the following codelines ar interpreted while animate() is running.

            Thank you

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