-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Qt Embedding w/ Spyder #13400
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
Comments
I've struggled with this alot. I found that the workaround you suggested sometimes worked, sometimes didn't. I would really like something that worked in both Spyder and in a script. |
Which part of the workaround, Issue 2? |
I'm not too sure. I just remember not to ask too much of opening applications from within spyder. I'm mostly expressing my support for applications supporting execcution from within spyder. Though I know it is challenging with so many different versions out there in the wild. |
I see, yeah I just tried out @ImportanceOfBeingErnest 's suggestion and using an external console is a good tool to be able to fall back on if needed. Though I like and am used to running everything within Spyder. While I have only been messing around with it recently for the past day or so, and using the most recent versions of spyder and matplotlib, I haven't had any issues with Kernel crashes or qapp.exec_() hanging using the workarounds I suggested. I noticed that there were quite a few forum threads out there that talked about this issue, so that is why I thought it might be nice to add a few extra lines or commented lines that would point people in the right direction. Though as you point out, what the 'right direction is' is complicated given the number of versions people might be using. |
I'm going to close this based on @ImportanceOfBeingErnest comment. Our examples are not meant to be run inside spyder or any other IDE, particularly those that spawn an application - if you ned help getting Qt apps running in spyder, that's probably better discussed as a spyder or Qt issue. Thanks! |
@gigo318 Could you open a PR with those changes? I think it is good practice to always do the "is there a running Qt app?" dance before creating a QApplication so we should demo that. |
Agreed with the change, however I think the |
Right now closing the window (in spyder) seems to return to the ipython console just fine, so I think this can be closed? |
@anntzer It only works with "Execute in an external console". Steps to reproduce:
|
I see the second plot appearing behind spyder, but not the blockage at the end that you report.
before the call to |
what about matplotlib master? what desktop environment? |
Indeed, works on master 😄. So after fixing the raise, this can be closed. |
@anntzer Sorry, didn't see the label. |
I have found a solution to a bug when using the script on:
https://matplotlib.org/gallery/user_interfaces/embedding_in_qt_sgskip.html
with the Spyder IDE (v3.3.2)
If the script is run as presented, two issues are present:
Issue 1: The qapp.exec_() does not terminate when the window is closed.
This was resolved for me by adding:
QtWidgets.QApplication.setQuitOnLastWindowClosed(True)
before qapp.exec_() is called:
Issue 2: When this script is called multiple times in the IPython console, the Kernel dies and must be restarted. Per the comment thread on issue #4349, this is solved by replacing:
qapp = QtWidgets.QApplication(sys.argv)
with
Can this be added to the example script?
Matplotlib version
The text was updated successfully, but these errors were encountered: