-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Start interactive loop #21
Comments
@fperez, any tips on how IPython does this? |
Don't know much about how it works (don't know much about python either - I am a matlab refugee_) . PS: Have looked through the PyCall code, and didn't find an obvious way to achieve the same effect as calling ipython --gui=... Unless it is possible to pass some kind of 'arguments' in ccall when loading the shared lib... |
No, it's not threads-based in IPython anymore, we use a Python input hook along with toolkit-specific implementations (in that same directory). |
We should be able to do something similar to IPython's input hook. Julia should have a way to register an event-loop task with its main event loop (it did at one point, but the functionality seems to have been renamed; see Julia issue #3099). We don't need any special arguments when the shared library is running; there is nothing special about the command line that cannot be done after the program starts. Since Julia has access to the full Python C API, it can do anything Python can do, and it's just a matter of telling MayaVi that the GUI event loop is already running. Looking at the source code for mayavi.mlab.show, it appears that this is done via |
It looks like the following should work to set up an event loop. Run I also have a GTK version working (but no QT version yet). The next task is to make this a bit more transparent, so that you don't have to call
|
The code above is working for me, with Mayavi. The only issue is that it mlab.show() should be detecting the running event loop...
Thanks a lot, Steven! (Edit: github should recognize julia code...) On Tue, May 21, 2013 at 9:40 PM, Steven G. Johnson <notifications@github.com
|
Try inserting a line |
@stevengj On Wed, May 22, 2013 at 4:46 AM, Steven G. Johnson <notifications@github.com
|
I don't think it should be an argument of I was thinking of just adding a macro @fperez, any thoughts? |
As you requested, this is a continuation of the discussion begun in #23 Following your suggestion, I switched to WX as the backend to matplotlib. Still no joy in avoiding blocking...
I tried your code both with and without the line I appreciate your continuing help on this. I dream of switching from Matlab to Julia with Matplotlib as the plotting engine (for now). |
@simonp0420, you need to tell matplotlib to use the WX backend (rather than the GTK default). You can do this by running Try e.g.
|
Success!! By testing subsets of the commands you provided, I found that the minimal set of commands that avoids blocking (for me) seems to be
The key thing that I was missing before is apparently the Thanks again! |
You can now just do For MayaVi or Chaco, just do |
I have added [weak reference support][1] for `pyjlwrap` types, following the documentation for Python 3+. Adding weak reference support for Python 2.x seems much the same as in 3.x, however 3.x does not use Py_TPFLAGS_HAVE_WEAKREFS, which also does not seem necessary for 2.x. Simple testing suggests that this is working as expected. Closes JuliaPy#21, JuliaPy#158 [1]: https://docs.python.org/3/extending/newtypes.html#weak-reference-support
I have added [weak reference support][1] for `pyjlwrap` types, following the documentation for Python 3+. Adding weak reference support for Python 2.x seems much the same as in 3.x, however 3.x does not use Py_TPFLAGS_HAVE_WEAKREFS, which also does not seem necessary for 2.x. Simple testing suggests that this is working as expected. Closes #21, #158 [1]: https://docs.python.org/3/extending/newtypes.html#weak-reference-support
Hi,
I am trying to use mayavi from julia. For now, it seems to work just fine, but the interaction with the gui only works after mlab.show(), which blocks julia; so, I can't programatically manipulate the mayavi pipeline from julia and interact with the mayavi gui...
In ipython the same happens, unless it is invoked with --gui=wx... can the same be achieved in PyCall?
Thanks.
Miguel Gaspar
The text was updated successfully, but these errors were encountered: