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
-
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!
-
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.
-
I'm trying to display
console.alert()
on a button press. -
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. -
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! -
Did the delay example work for you in XCode?
The alternative, of course, is to roll your ownalert
out of ui components, rather than usingconsole.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 usingwait_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 usehidden
to show or hide the alert.