Displaying current output in wx.textctrl wigdet from python code entered in another wx.textctrl
Question: I use two wx.TextCtrl widgets in my wxApp.  
The first one is used to provide Python code by app user, e.g.:

    
    
    from time import sleep  
    for i in range(4):  
        print i  
        sleep(4)  
    

The second one is used to display the output.  
To process user code I use EXEC.  
But I have problems with displaying output dynamically.

Currently the output is displayed in second wx.TextCtrl widget but after whole
code is processed (after 16 seconds).

I would like to display the user's code output every 4 seconds in above code.
How to do that?

I was trying to use threads but there are problems with using exec in case of
threads.


Answer: time.sleep will block the GUI's main loop, which is why you don't see any
output. You will have to put that into a separate thread if you want to go
that route. Otherwise, you could use a wx.Timer.

Here's a tutorial: <http://www.blog.pythonlibrary.org/2009/08/25/wxpython-
using-wx-timers/>

I don't think you should use Python's exec command though. That can lead to
code injection issues. Instead, you should consider using the subprocess
module.

