Skip to content
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

Crash when scroll on figure #9849

Closed
Goczilla opened this issue Nov 24, 2017 · 1 comment
Closed

Crash when scroll on figure #9849

Goczilla opened this issue Nov 24, 2017 · 1 comment

Comments

@Goczilla
Copy link

Goczilla commented Nov 24, 2017

Bug report

Bug summary

When I use the scroll of the mouse (even without mpl_connect("scroll_event")), the GUI crash. I want to modify the scroll_event function to zoom/dezoom. I already did this in my previous GUI in which it works well.
BUT, no crash with the minimalist example:

import matplotlib.pyplot as plt
plt.figure()
plt.show()

This example is from my real GUI in which I promote a widget in QtDesigner as MPL_Widget_solo.

Code for reproduction

from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

class MyMplCanvas(FigureCanvas):
    def __init__(self, parent=None):
        self.fig = Figure()
        FigureCanvas.__init__(self, self.fig)
        FigureCanvas.setSizePolicy(self,
                                   QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

class MPL_Widget_solo(QWidget):
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)
        self.canvas = MyMplCanvas()
        self.vbox = QVBoxLayout()
        self.vbox.addWidget(self.canvas)
        self.setLayout(self.vbox)

class Ui_Form(object):
    def setupUi(self, Form):
        self.gridLayout = QGridLayout(Form)
        self.widget = MPL_Widget_solo(Form)
        self.gridLayout.addWidget(self.widget, 0, 0, 1, 1)

class Plot_Widget(QWidget, Ui_Form):
    def __init__(self, parent=None):
        super(Plot_Widget, self).__init__(parent)
        self.setupUi(self)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    plot = Plot_Widget()
    plot.show()
    sys.exit(app.exec_())

Actual outcome

`Process finished with exit code 1`

Expected outcome

I wish to modify the scroll event to zoom/dezoom (already done in other GUI in which it works).

Matplotlib version

  • Operating system: windows 7 Pro
  • Matplotlib version: 2.1.0 (installed via anaconda)
  • Matplotlib backend: Qt5Agg
  • Python version: 3.6
  • Other libraries: PyQt5
@tacaswell
Copy link
Member

I think the problem is from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas which should be

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas

to use the classes which use the correct multiple inheritance super class calling mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants