I did re-try this ctypes version on wx 2.8 and it has the same
problem as before. When you get a chance, it would be great if you
could help figure out what is going on with 2.8.
After digging around in the wx.App code, I found that one of the default arguments was chagned in 2.9. The argument is redirect. It was True in 2.8, and in 2.9 it is False. Setting it to False makes everything work fine on 2.8.
Ah, I hadn't thought of the stdout redirect since I almost always turn it off myself. I'm glad you found this before I wasted time chasing my tail in some other direction. You can add a call to app.RestoreStdio to your inputhook script to make sure that the stdout is where it needs to be.
Just a warning, the wx.App doc strings in 2.9 have not been updated to reflect this change.
People from various projects have been testing the PyOS_InputHook stuff in various settings. Overall, the results have been good. But, some users are reporting slow GUI responses, which this new stuff is used interactively. Here is the current hypothesis about what the performance issue is related to:
The chunkiness probably comes from the fact that inputhook_wx is called repeatedly.
And the frequency of those calls will play a big role in the responsiveness of the GUI. IOW, events will be processed (in short bursts) only as often as the input hook is called.
[...]
Do you have any ideas on how these issues can be addressed. Obviously, being able to monitor stdin in the event loop would help, but it sounds like that isn't possible yet.
Something that can be done today with 2.8 is to add the outer loop I mentioned in a previous message, controlled by a function that is polling the stdin for input-readiness. Then it will stay in the event loop until there is input available for the interactive interpreter and won't depend on the hook being called more than once and/or often.