DoEvents equiv?
Mark Hammond
MarkH at ActiveState.com
Thu May 10 19:31:30 EDT 2001
Carlos Ribeiro wrote:
> At 22:58 09/05/01 +0000, Mark Hammond wrote:
>
>> Carlos Ribeiro wrote:
>>
>>> 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.
>
>
> I'm not an expert on this issue,
But don't let that stop you :)
> but, as far as I know, it doesn't depend on the GUI system.
It does.
> It's just a matter of calling PumpMessages, from the Win32 library.
There is no such call in the Win32 library.
Each app provides its own event loop. DoEvents/PumpMessages dispatches
events waiting in the event queue. Different apps have different
requirements for their event queues. For example, Tkinter has a very
complex event loop, and it is almost certain that a simple event loop
would not work for Tkinter.
> All Win32 applications should honor this call.
What call?
> Mark, it's not lazyness. The problem is that you can't just put it in a
> single line of code. You have to scatter calls to
> pythoncom.PumpWaitingMessages all over the place, specially if you are
> doing something more complex. And using threads just for this is
> overkill.
I disagree. If you are writing a GUI app, you should design an
architecture so that the GUI does not block for long periods of time.
What happens if during your PumpMessages() call, the user actually
selects a different menu item, and recursively starts an operation?
> Also, note that this call is not available under Linux, so you
> have to take this in account also (test the os, load pythoncom only on
> Win32...).
So what do you suggest we use for Linux? If we can not define a
standard event loop for a Windows app, I doubt we will be able to for Linux.
If you really believe we can do this, submit some patches.
Mark.
More information about the Python-list
mailing list