-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Milestone
Description
Bug report
Bug summary
Sometimes, when closing a window containing a matplotlib figure with active event handling, a “TypeError: isinstance()” is raised (confirmed when using the 'X'-button to close). I was able to raise the error about every other time by moving the cursor over the figure or clicking on it and quickly closing the window afterwards. So far, I found that this only happens if at least any two of the event handling connections are active.
Code for reproduction
import sys
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import \
FigureCanvasQTAgg as FigureCanvas
from PyQt5.QtWidgets import QDialog, QApplication, QGridLayout
class Figure:
def __init__(self):
self.fig, self.ax = plt.subplots()
self.canvas = FigureCanvas(self.fig)
self.canvas.setMaximumHeight(100)
self.fig.canvas.mpl_connect('pick_event', self.on_pick_event)
self.fig.canvas.mpl_connect(
'button_release_event', self.on_release_event
)
self.fig.canvas.mpl_connect(
'button_press_event', self.on_button_press_event
)
self.fig.canvas.mpl_connect(
'motion_notify_event', self.on_motion_event
)
self.canvas.draw()
def on_pick_event(self, _):
# print('picked')
pass
def on_button_press_event(self, _):
# print('pressed')
pass
def on_release_event(self, _):
# print('released')
pass
def on_motion_event(self, _):
# print('moved')
pass
class MainWindow(QDialog):
def __init__(self):
super().__init__()
self.layout = QGridLayout(self)
self.image = Figure()
self.layout.addWidget(self.image.canvas, 1, 0)
if __name__ == '__main__':
app = QApplication(sys.argv)
GUI = MainWindow()
GUI.show()
sys.exit(app.exec_())
Actual outcome
Exception ignored in: <function WeakMethod.__new__.<locals>._cb at 0x00000193A3D7C7B8>
Traceback (most recent call last):
File "C:\Users\mapf\Anaconda3\lib\weakref.py", line 58, in _cb
File "C:\Users\mapf\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 182, in _remove_proxy
File "C:\Users\mapf\Anaconda3\lib\weakref.py", line 74, in __eq__
TypeError: isinstance() arg 2 must be a type or tuple of types
Expected outcome
No errors.
Matplotlib version
- Operating system: Windows 10 Home 64bit
- Matplotlib version: 3.0.0 (via anaconda default installation)
- Matplotlib backend: Qt5Agg
- Python version: 3.5.6
Metadata
Metadata
Assignees
Labels
No labels