Skip to content

Qt Embedding w/ Spyder #13400

@gigo318

Description

@gigo318

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy