[IPython-User] Non-blocking QT window from the notebook

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[IPython-User] Non-blocking QT window from the notebook

Jack Zentner
I've been using the notebook to play around with PySide and in general everything works beautifully.  From it, I can create arbitrarily complex QT UIs, launch them and interact with them. However, in playing with PySide I thought it would be really useful if I could prototype UI elements from the notebook without having to load and then close the QT window to evaluate and make changes.  I'm thinking of a non-blocking UI that allows for interactive building and updating kind of like you can do with matplotlib plots that are launched from the notebook.  

To try to recreate the matplotlib functionality, I've dug through the matplotlib src to see how they do it when using a QT backend but I can't seem to recreate their non-blocking functionality. It seems the basic matplotlib pattern is to create a QApplication instance, create a QMainWindow, add a central widget to it, show the main window and run exec_ on the qApp.  However when I implement this pattern it creates a blocking QT window that won't return control back to the notebook until the window is closed.  Clearly I'm missing something in how matplotlib is able to create a non-blocking window.

Does anyone have some insight into how I might achieve a non-blocking QT window from the notebook?  Or can tell me how matplotlib is able to do this?

Thank you in advance,

Jack
Reply | Threaded
Open this post in threaded view
|

Re: Non-blocking QT window from the notebook

Thomas Kluyver-2
Hi Jack,

Yep, IPython includes event loop integration to do just what you're talking about. To use it, you need to run '%gui qt' in IPython, and then start the event loop in a special way. See this example:

https://github.com/ipython/ipython/blob/master/examples/IPython%20Kernel/gui/gui-qt.py

By the way, we're slowly deprecating the ipython-user list and merging all conversation into ipython-dev, so in future, you may want to ask questions there. We also check Stackoverflow and our Gitter chat room.

Thanks,
Thomas

On 31 October 2014 11:56, Jack Zentner <[hidden email]> wrote:
I've been using the notebook to play around with PySide and in general
everything works beautifully.  From it, I can create arbitrarily complex QT
UIs, launch them and interact with them. However, in playing with PySide I
thought it would be really useful if I could prototype UI elements from the
notebook without having to load and then close the QT window to evaluate and
make changes.  I'm thinking of a non-blocking UI that allows for interactive
building and updating kind of like you can do with matplotlib plots that are
launched from the notebook.

To try to recreate the matplotlib functionality, I've dug through the
matplotlib src to see how they do it when using a QT backend but I can't
seem to recreate their non-blocking functionality. It seems the basic
matplotlib pattern is to create a QApplication instance, create a
QMainWindow, add a central widget to it, show the main window and run exec_
on the qApp.  However when I implement this pattern it creates a blocking QT
window that won't return control back to the notebook until the window is
closed.  Clearly I'm missing something in how matplotlib is able to create a
non-blocking window.

Does anyone have some insight into how I might achieve a non-blocking QT
window from the notebook?  Or can tell me how matplotlib is able to do this?

Thank you in advance,

Jack



--
View this message in context: http://python.6.x6.nabble.com/IPython-User-Non-blocking-QT-window-from-the-notebook-tp5076285.html
Sent from the IPython - User mailing list archive at Nabble.com.
_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user


_______________________________________________
IPython-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/ipython-user
Reply | Threaded
Open this post in threaded view
|

Re: Non-blocking QT window from the notebook

Jack Zentner
Thomas,

Fantastic!  Your suggestion worked like a champ.  In case anyone cares, I've attached an example notebook that demonstrates how to create a non-blocking QT window from the IPython Notebook.

Thank you again,

jack

InteractiveGuiBuilding.ipynb