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.


    ui.in_background and threading with Xcode

    Pythonista
    2
    6
    3698
    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.
    • Gerzer
      Gerzer last edited by

      I was wondering if anyone knew how to use ui.in_background with Xcode? Whenever I try to use it or the threading module my standalone app crashes. Thanks!

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

        What are you trying to backround, and when?

        I have found that if you are trying to run a thread at the same time as some animation on the main ui thread, things crash or become non responsive. Try a ui.delay or threading.Timer to separate what you are doing from any animations, or things like opening/closing views,etc.

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

          I'm trying to display console.alert() on a button press.

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

            Do you actually need an alert? As opposed to just a hud_alert?

            See this. The solution seems to be adding a delay to ensure nothing else is trying to draw, or animate at that time. For instance, if you do a long animate, you need to delay long enough so the animation is done.

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

              I do need a console.alert() as I want the user to select a button or type in some text. The thing is, extremely similar code works in Pythonista, but when I put it in Xcode it doesn't work. Thanks!

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

                Did the delay example work for you in XCode?
                The alternative, of course, is to roll your own alert out of ui components, rather than using console.alert. One way I've done something similar is that you would have another alert view that covers the full screen, is partially transparent ( bg_color takes a 4tuple, and the fourth entry is alpha), and contains a subview which is the actual alert. Having the containing view full screen lets you implement a modal type dialog, by blocking touch events for anything underneath, without actually using wait_modal, which has its own problems sometimes. You need to make sure your new view is at the top of the view stack (added last for example), but then can use hidden to show or hide the alert.

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