Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Qt Embedding w/ Spyder #13400

Copy link
Copy link
Closed
Closed
Copy link
@gigo318

Description

@gigo318
Issue body actions

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:

if not QtWidgets.QApplication.instance():
    qapp = QtWidgets.QApplication(sys.argv)
else:
    qapp = QtWidgets.QApplication.instance()
QtWidgets.QApplication.setQuitOnLastWindowClosed(True)

app = ApplicationWindow()
app.show()
qapp.exec_()

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

if not QtWidgets.QApplication.instance():
    qapp = QtWidgets.QApplication(sys.argv)
else:
    qapp = QtWidgets.QApplication.instance()

Can this be added to the example script?

Matplotlib version

  • Operating system: Windows 10
  • Matplotlib version: 3.0.2
  • Python version: 3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.