Threads with Python in Desktop
Does Titanium Desktop support threads at all that can access the GUI? For example, I have a python program that I want to be able to update when it receives notifications. I can't seem to get it to work as it either stalls if I use a standard loop or if I spawn a thread it seems to not update the GUI.
Any ideas/thoughts?
Thanks!
-rob
2 Answers
-
Got it figured out and thought I'd share with others in similar situations!
WebKit is not thread safe, so python threads can not update the GUI/DOM. What you can do though is create some python functions and call them using Titanium.API.runOnMainThread(function, …) from your threads passing in the information you want to propagate to the GUI/DOM and it will update it for you on the main thread.
Works pretty slick and keep your app working great!
Hope it helps others!
-rob
-
Thanks, this worked great for me.
A note, in the new version of appcelerator. Calling the javascript function name doesn't work. You have to do window.function_name. Everything worked for me once I did thi.