Activate event handler and SetWindowPos()

Probably not, since SetWindowPos() isn't in the standard
libraries. Can you suggest an alternate approach that
would bypass the use of the activate event?

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Monday, February 17, 2003 4:32 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Activate event handler and SetWindowPos()

Jeff Kotula wrote:

Hi all. I've got a C++ application with an embedded Python interpreter,
running wxPython for the UI layer on Windows XP. At one point, I use the
SetWindowPos() Windows function to raise and activate a different
application. This works fine until I set up an event handler for the
activate event (either the app or frame). It totally hangs the application.

Note that it is just the fact that an event handler is set up that is causing
the problem: if the handler has nothing but "event.Skip()" it still hangs.

Any ideas?

Can you reproduce the problem in a Python-only app?

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

________________________________________________________________________
This email has been scanned for all viruses and found to be virus free. If you have questions regarding this scanning please visit the Information Services area of http://home.vitalimages.com
________________________________________________________________________

Jeff Kotula wrote:

Probably not, since SetWindowPos() isn't in the standard
libraries. Can you suggest an alternate approach that
would bypass the use of the activate event?

SetWindowPos is in module win32gui from the win32all Python libraries:

http://starship.python.net/crew/mhammond/

though I haven't tried using it.

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Monday, February 17, 2003 4:32 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Activate event handler and SetWindowPos()

Jeff Kotula wrote:

Hi all. I've got a C++ application with an embedded Python interpreter,
running wxPython for the UI layer on Windows XP. At one point, I use the
SetWindowPos() Windows function to raise and activate a different
application. This works fine until I set up an event handler for the
activate event (either the app or frame). It totally hangs the application.

Note that it is just the fact that an event handler is set up that is causing
the problem: if the handler has nothing but "event.Skip()" it still hangs.

Any ideas?

Can you reproduce the problem in a Python-only app?

David C. Fox wrote:

Jeff Kotula wrote:

Probably not, since SetWindowPos() isn't in the standard
libraries. Can you suggest an alternate approach that
would bypass the use of the activate event?

SetWindowPos is in module win32gui from the win32all Python libraries:

http://starship.python.net/crew/mhammond/

though I haven't tried using it.

Sorry - should have mentioned the build: it is definitely in win32all build 150, but might have been in earlier versions as well.

David

Jeff Kotula wrote:

Probably not, since SetWindowPos() isn't in the standard
libraries.

Well, what I was really asking is if you could duplicate the problem without the C++ part of your app, and therefore without SetWindowPos. OTOH, does anybody know if SetWindowPosition or SetForegroundWindow is in the win32api extension modules? That would let you totally simulate the situation in Python.

Hi all. I've got a C++ application with an embedded Python interpreter,
running wxPython for the UI layer on Windows XP. At one point, I use the
SetWindowPos() Windows function to raise and activate a different
application. This works fine until I set up an event handler for the
activate event (either the app or frame). It totally hangs the application.

Note that it is just the fact that an event handler is set up that is causing
the problem: if the handler has nothing but "event.Skip()" it still hangs.

Any ideas?

Some more questions:

Does it happen when you call SetWindowPos or when you are coming back and reactivating your app? If the former try putting a breakpoint in wxPyCallback::EventThunker just before the the call to SetWindowPos happens. Does it get stuck on the call to wxPyBeginBlockThreads? If so then you've got a problem dealing with the Python global interpreter lock as you already have the GIL and it is blocking waiting for it to be released, resulting in a deadlock.

The general rule is that any calls from Python to native code need to be wrapped in calls to wxPyBeginAllowThreads and wxPyEndAllowThreads. Calls from native code back to Python (event handlers, or even anything that can manipulate PyObjects) needs to be wrapped in calls to wxPyBeginBlockThreads and wxPyEndBlockThreads. This is all handled automatically within wxPython, but by embedding in a C++ app you are adding a new wrinkle and need to take care to treat the GIL right.

Does this help?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!