omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. ZinoSama

    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.


    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 7
    • Best 0
    • Controversial 0
    • Groups 0

    ZinoSama

    @ZinoSama

    0
    Reputation
    274
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    ZinoSama Unfollow Follow

    Latest posts made by ZinoSama

    • RE: App crashes on a long running button action

      @cvp the 361 one is the value I forget to change for testing.
      I wrote a simple while loop to test button action. The result is the label will only show 10 after 10 seconds, but not get from 1 to 10 by each second. it just didn't show 1 to 9

      def start2(sender):
      	label = sender.superview['label1']
      	num = 0
      	while num != 10:
      		time.sleep(1)
      		num += 1
      		label.text = str(num)
      
      posted in Pythonista
      ZinoSama
      ZinoSama
    • RE: App crashes on a long running button action

      it seems like I can’t put a whole loop into button action, but I want to do a counter by time function.

      posted in Pythonista
      ZinoSama
      ZinoSama
    • App crashes on a long running button action

      I tried debug this code, and it worked correctly, but after I running this one, the whole app crushed.

      def start(sender):
      	def ani_pause():
      		sender.image = ui.Image.named('iob:pause_32')
      
      	def ani_play():
      		sender.image = ui.Image.named('iob:play_32')
      
      	global is_playing
      
      	if is_playing is False:
      		ui.animate(ani_pause)
      		is_playing = True
      		start_time = time.time()
      		label = sender.superview['label1']
      		label2 = sender.superview['label2']
      		time_left = 0
      		while int(label.text) != 131:
      			time.sleep(0.01)
      			time_now = time.time()
      			duration = time_now - start_time
      			time_left += 1
      			label2.text = str(10 - time_left)
      			if label2.text is '0':
      				label.text = str(int(label.text) + 1)
      				time_left = 361
      		ui.animate(ani_play)
      		is_playing = False
      	else:
      		is_playing = False
      		ui.animate(ani_play)
      
      posted in Pythonista
      ZinoSama
      ZinoSama
    • RE: How to change the button image?

      @cvp oops, didn’t notice that. Let me try it.

      posted in Pythonista
      ZinoSama
      ZinoSama
    • RE: How to change the button image?

      @ccc you are right, I already changed it. It is still stuck though

      posted in Pythonista
      ZinoSama
      ZinoSama
    • RE: How to change the button image?

      Thank you, guys, just by adding 'iob:' makes it working.
      Now I get another problem, I have a button action link to this function, and every time I press this button, the whole Pythonista will stuck.

      state = False
      def start(sender):
      	def ani_pause():
      		sender.image = ui.Image('iob:pause_32')
      
      	def ani_play():
      		sender.image = ui.Image('iob:play_32')
      
      	global state
      	if state is False:
      		ui.animate(ani_pause)
      		state = True
      		start_time = round(time.time())
      		label = sender.superview['label1']
      		label2 = sender.superview['label2']
      		while int(label.text) != '131':
      			time_now = round(time.time())
      			duration = time_now - start_time
      			time_left = divmod(duration, 360)[1]
      			label2.text = str(time_left)
      			if time_left == 0:
      				label.text = str(int(label.text) + 1)
      			else:
      				continue
      		ui.animate(ani_play)
      		state = False
      	else:
      		state = False
      		ui.animate(ani_play)
      
      posted in Pythonista
      ZinoSama
      ZinoSama
    • How to change the button image?

      How do I change the button image from 'play' to 'pause'?
      Something like press button once, the image change to 'pause', then press it again, the image change back to 'play'.
      What I did is

      sender. Image = ui.Image.named('pause_32')
      

      This will make the button blank, totally white

      posted in Pythonista
      ZinoSama
      ZinoSama