DoEvents equiv?

Mark Hammond MarkH at ActiveState.com
Wed May 9 18:58:07 EDT 2001


Carlos Ribeiro wrote:

> At 12:50 09/05/01 +0000, Mark Hammond wrote:
>> It really depends on the GUI system you are running.  In many cases, 
>> PumpMessages in either win32ui, win32gui or pythoncom will do the job. 
>> For a Tkinter app, it will be something different, but I don't know 
>> what that is.
> 
> 
> Mark, don't you think that it would make sense for the Python 
> interpreter to have some option to call PumpMessages internally from 
> time to time? It's part of being a good citizen of Windowsland. I was 
> wondering if it is possible to make a call from inside the interpreter, 
> yielding control back to Windows periodically.


As I mentioned, it depends on the GUI system.  I dont know how Python 
could implement this so it works with MFC, Win32GUI, wxPython and 
Tkinter apps.

Also, I don't see the value in added complexity just to save you one 
line in your code.

> This would bring some benefits. I work with some scripts that read long 
> text files, and sometimes it does take a few minutes to finish 
> processing. Sometimes I just can't break into the code. Sometimes the 
> activate or break options of PythonWin (on the systray) are not enough, 
> because the intepreter simply does not help. I noticed that PythonWin 
> 210 is a little bit more responsive, but the problem still happens from 
> time to time.


It is very rare that this will be the best solution.  It provides plenty 
of reentrancy problems.  Use a new thread, and notify the main GUI 
thread with results, for example.


Mark.




More information about the Python-list mailing list