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.


    How to prevent button flickering on title change?

    Pythonista
    button ui module
    2
    5
    3350
    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.
    • FrankenApps
      FrankenApps last edited by

      Whenever I update the title of a ui.button an animation is shown (so it appears as if the button flickers).

      This seems to be normal on iOS, and this is how it can be prevented in native Apps: https://stackoverflow.com/questions/18946490/how-to-stop-unwanted-uibutton-animation-on-title-change

      Is there a way to prevent this animation in Pythonista (for example using obj_c )?

      I would really like to use a button and not a custom view...

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

        @FrankenApps same here

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @FrankenApps last edited by

          @FrankenApps this has worked but no more today, don’t know why

          import ui
          from objc_util import *
          
          UIButton = ObjCClass('UIButton') 
          
          class my:
          	def __init__(self):
          		pass
          		
          	def handler(self,_cmd,obj1_ptr):
          		print('handler',self.title)
          		self.UIButton.title = self.title
          
          	def setTitleWithoutAnimation(self,ui_button, title):
          		o = ObjCInstance(ui_button)    
          		self.UIButton = False
          		for subview in o.subviews():
          			if subview.isKindOfClass(UIButton):   
          				self.UIButton = subview
          				break  
          		if not self.UIButton:
          			return
          		self.title = title
          		block = ObjCBlock(self.handler, restype=None, argtypes=[c_void_p, c_void_p])
          		# class/type method, not instance method
          		UIButton.animateWithDuration_animations_(0,block)
          
          
          m=my()
          v = ui.View()
          v.frame =(0,0,100,100)
          b = ui.Button()
          b.frame = (10,10,80,32)
          b.title = 'tap'	
          def b_action(sender):
          	m.setTitleWithoutAnimation(sender,'done')
          b.action = b_action
          v.add_subview(b)
          v.present('sheet')
          
          FrankenApps 1 Reply Last reply Reply Quote 0
          • FrankenApps
            FrankenApps @cvp last edited by

            @cvp Thanks, I‘ll Play around with this a bit. I have Not seen that other thread, so sorry for the duplicate..

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @FrankenApps last edited by

              @FrankenApps no problem, often not easy to search in forum, better to search via google 😃

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