I'm writing a library (C++ with Python API) that needs to open OpenGL 
windows, and display interactive content there.

Apologies for cross-posting, i'm new to asking questions here, and wasn't 
really sure if the mailing list or the GitHub Jupiter help project was the 
best place to ask questions. I also posted this question on GitHub at 

https://github.com/jupyter/help/issues/438

Let me know where's the best place to ask questions, and I'll just post 
there from now on. 

In my app, I want users to be able to invoke this lib directly from the 
ipython interactive console, have it open a few windows, return AND then 
continue listening for user input at the console. Effectively, I want the 
user experience to be like

s = Simulator()

s.showWindows() # this method should open some windows and return instantly

s.runAsync()    # this method will start the sim, display live content in 
the windows, 

# and return

# the user is now back at the console prompt, with open windows with 
content. 

# the user now wants to tweak some parameters:

s.tweakSomeParameter() # the simulation is running in the background, 

# and the user here can tweak values.  


I've just started reading up on the C PyOS_InputHook routine, and this 
looks like the *PERFECT* way to hook up my own GUI event processing. Is 
there any issues using this with ipython interactive terminal

But it looks like the IPython.lib.inputhook module has been deprecated. 
What has replaced this? Could you point me to some examples / docs where 
interactive GUI toolkits have installed their own message loop, preferably 
via the C PyOS_InputHook routine.

https://ipython.readthedocs.io/en/stable/api/generated/IPython.lib.inputhook.html

On Mac OSX, the message loop MUST BE ON THE MAIN THREAD. I've written a Mac 
message loop, looks something like:

- (void)run

{

    shouldKeepRunning = YES;

    do

    {

        // memory autorelease pool stuff...


       // this absolutely must be called on main thread

        NSEvent *event =

            [NSApplication

                nextEventMatchingMask:NSAnyEventMask

                untilDate:[NSDate distantFuture]

                inMode:NSDefaultRunLoopMode

                dequeue:YES];


       // also must be called on main thread. 

        [NSApplication sendEvent:event];

        // update windows, do stuff...

    } while (shouldKeepRunning);


    // pool stuff

}

What I could do, is on the C side, create some Python wrapper functions for 
the [NSApplication ... nextEventMatchingMask and [NSApplication 
sendEvent:event] calls, and then tie these into a custom main loop in 
python that combines the existing ipython interactive terminal with these 
window handling message calls.

So, my question is how can I integrate the Mac window GUI message loop with 
the ipython interactive terminal main loop? Is is possible to override the 
ipython interactive terminal main loop? Could you point me towards the 
source where it's at?

Ideally, I'd like to do so method like this:

# user is sitting, typing away at ipython interactive terminal, and 

# they load my library:


from Mechanica import simulator as s

s.installHooks()


Then my installHooks method would find the ipython interactive terminal 
main loop, either hook into it override it with with my own loop which 
invokes the two Cocoa GUI message handling routines.

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/afc289ea-4273-4efb-906a-b8be63b35cd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to