<br><br><div class="gmail_quote">On Sat Dec 27 2014 at 6:58:23 PM Matthias Bussonnier <<a href="mailto:bussonniermatthias@gmail.com">bussonniermatthias@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div>Le 28 déc. 2014 à 00:24, Darren Dale <<a href="mailto:dsdale24@gmail.com" target="_blank">dsdale24@gmail.com</a>> a écrit :</div></div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite">I passed None because <a href="http://ipython.org/ipython-doc/stable/api/generated/IPython.terminal.embed.html?highlight=embed#IPython.terminal.embed.InteractiveShellEmbed" target="_blank">http://ipython.org/ipython-doc/stable/api/generated/IPython.terminal.embed.html?highlight=embed#IPython.terminal.embed.InteractiveShellEmbed</a> states: "If given as None, they are automatically taken from the scope where the shell was called, so that program variables become visible." That is precisely what I want, but can't figure out how to do it with the Qt console.</blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>As far as I am concerned, you are not using InteractiveShellEmbed, I don't see why you apply docs of one function to </div><div>another.</div></div></div></blockquote><div><br></div><div>Well, there is not much to be gleaned from the qt in-process documentation at <a href="http://ipython.org/ipython-doc/stable/api/generated/IPython.qt.inprocess.html#module-IPython.qt.inprocess">http://ipython.org/ipython-doc/stable/api/generated/IPython.qt.inprocess.html#module-IPython.qt.inprocess</a> . If I call `embed` after I start the kernel and client, I recall getting an error about attempting multiple instantiations of InteractiveShellEmbed, so it seemed reasonable to assume that the **kwargs listed in the in-process docs might map to those documented for InteractiveShellEmbed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>I don't want to inject variables to an isolated namespace, I want the console to share the application's namespace.</div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>I did not tell you to pass an isolated namespace, I did tell you to pass `globals()` it is not isolated is is a reference to </div><div>current global namespace so it should be shared :</div></div></div></blockquote><div><br></div><div>My mistake. I guess I misunderstood your comment "<span style="font-size:13.1999998092651px;line-height:19.7999992370605px">You can also do as raymond said, and inject things into user_ns after getting the reference to it.</span><span style="font-size:13.1999998092651px">" That sounds like it injecting variables into an isolated namespace.</span></div><div><span style="font-size:13.1999998092651px"><br></span></div><div><span style="font-size:13.1999998092651px">I'd try passing globals() instead of None, but I don't know how that should be done. </span><span style="font-size:13.1999998092651px"><a href="http://ipython.org/ipython-doc/stable/api/generated/IPython.qt.inprocess.html#module-IPython.qt.inprocess">http://ipython.org/ipython-doc/stable/api/generated/IPython.qt.inprocess.html#module-IPython.qt.inprocess</a> only lists **kwargs, and it sounds like the arguments listed for InteractiveShellEmbed do not necessarily apply to the qt.inprocess functions/methods.</span></div><div> </div><div>[...]</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><div>So here, you just need to do it yourself (example a), as the kernel is potentially on a different process</div></div></div></div></blockquote><div><br></div><div>qt.inprocess is in-process, isn't it?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><br><div class="gmail_quote">On Sat Dec 27 2014 at 6:02:54 PM Matthias Bussonnier <<a href="mailto:bussonniermatthias@gmail.com" target="_blank">bussonniermatthias@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div>Le 27 déc. 2014 à 23:43, Darren Dale <<a href="mailto:dsdale24@gmail.com" target="_blank">dsdale24@gmail.com</a>> a écrit :</div></div><div style="word-wrap:break-word"><br><blockquote type="cite">Thanks Ray. Unfortunately, I want the ipython console's namespace to reflect that of the application in which it is embedded, not a specific widget. There is an example that appears to do this at <a href="https://github.com/ipython/ipython/blob/master/examples/Embedding/embed_function.py" target="_blank">https://github.com/ipython/ipython/blob/master/examples/Embedding/embed_function.py</a> , but I'm trying to do the same with the Qt widget. At the top of my main gui module, I do:<br><div><br></div><div><div>try:</div><div>    from IPython.qt.console.rich_ipython_widget import RichIPythonWidget</div><div>    from IPython.qt.inprocess import QtInProcessKernelManager</div><div><br></div><div>    # Create an in-process kernel</div><div>    kernel_manager = QtInProcessKernelManager(user_ns=None)</div></div></blockquote><div><br></div></div><div style="word-wrap:break-word"><div>Don't you want to just pass `globals()` instead of `None` here? </div><div>user_ns kwarg here is **the mutable namespace** (i.e. a dict) you want your kernel to work on.  If you pass None, </div><div>it will create a new empty object for you. If you pass `{"a":1}` then your kernel will see a variable `a` with a value of 1 (mutable) </div><div><br></div><div>So I guess what you want to pass here is either globals(), locals(), or a dict you constructed yourself, </div><div>from the bit you want available. </div><div><br></div><div>You can also do as raymond said, and inject things into user_ns after getting the reference to it. </div></div><div style="word-wrap:break-word"><div>-- </div><div>M</div><div><br></div></div>______________________________<u></u>_________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/<u></u>listinfo/ipython-dev</a><br>
</blockquote></div>
_______________________________________________<br>IPython-dev mailing list<br><a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br><a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br></blockquote></div></div>______________________________<u></u>_________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/<u></u>listinfo/ipython-dev</a><br>
</blockquote></div>