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.


    Incremental textView content

    Pythonista
    3
    7
    3349
    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.
    • rb
      rb last edited by

      Next question:)
      Is it possible to animate the .text attribute of a ui textView?
      Ie print the text one letter or a few letters at a time?
      Any pointers on how best to do this?

      cvp 2 Replies Last reply Reply Quote 0
      • cvp
        cvp @rb last edited by

        @rb Not sure it is what you want

        import ui
        full = 'this is the entire text'
        tv = ui.TextView()
        tv.text = ''
        tv.present('sheet')
        def animation():
        	global full
        	tv.text = full[:len(tv.text)+1]
        	if tv.text != full:
        		ui.delay(animation,0.2)
        ui.delay(animation,0.2)
        
        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @rb last edited by

          @rb or

          import ui
          class mytv(ui.View):
          	def __init__(self, *args, **kwargs):
          		super().__init__(*args, **kwargs)
          		self.update_interval = 0.2
          		self.tv = ui.TextView()
          		self.tv.text = ''
          		self.add_subview(self.tv)
          		self.full = 'this is the entire text' 
          	def update(self):
          		self.tv.text = self.full[:len(self.tv.text)+1]
          		if self.tv.text == self.full:
          			self.update_interval = 0.0		
          v = mytv()
          v.present('sheet')
          
          1 Reply Last reply Reply Quote 0
          • rb
            rb last edited by

            Thankyou! Exactly what I wanted - delay() was what I needed

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

              @rb, note that in my experience, using the update method is more stable.

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

                And if you are going to be adding lots of these small nice animations, I will plug my Scripter module, that e.g. has reveal_text available as a simple function to call on a textual view.

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

                  @mikael awesome I will check this out looks like exactly what I’m after thankyou :)

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