I am self teaching myself some python OOP, and I have created a simple GUI that starts a number of scripts in the background using Popen. I need to determine at all times whether these scripts are active or not, which I was going to use a loop for.
But how can I have a loop running in the background at all times, without disrupting the user’s ability to use the GUI?
You must run a thread in the background. A thread is simply a set of code that runs at the same time as anyother thread. A python program for example is one thread, only one action can occur at any one time, which is why you will see a lag with a infinite loop and a gui. If you create a new thread though the gui will run in one thread, and the loop in a separate thread. This is in a perfect world.
Look further on google threading in python, but here are some links:
http://www.prasannatech.net/2008/08/introduction-to-thread-programming.html
http://www.wellho.net/solutions/python-python-threads-a-first-example.html
http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/
Good luck