Skip to content

Commit c9f5c3b

Browse files
author
Quentin Peter
committed
fix subplot dialog
1 parent 423f465 commit c9f5c3b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ def __init__(self, canvas, parent, coordinates=True):
605605

606606
self.coordinates = coordinates
607607
self._actions = {} # mapping of toolitem method names to QActions.
608+
self._subplot_dialog = None
608609

609610
for text, tooltip_text, image_file, callback in self.toolitems:
610611
if text is None:
@@ -714,9 +715,10 @@ def remove_rubberband(self):
714715

715716
def configure_subplots(self):
716717
image = str(cbook._get_data_path('images/matplotlib.png'))
717-
dia = SubplotToolQt(self.canvas.figure, self.canvas.parent())
718-
dia.setWindowIcon(QtGui.QIcon(image))
719-
dia.show()
718+
self._subplot_dialog = SubplotToolQt(
719+
self.canvas.figure, self.canvas.parent())
720+
self._subplot_dialog.setWindowIcon(QtGui.QIcon(image))
721+
self._subplot_dialog.show()
720722

721723
def save_figure(self, *args):
722724
filetypes = self.canvas.get_supported_filetypes_grouped()
@@ -800,13 +802,14 @@ def __init__(self, targetfig, parent):
800802
self._figure = targetfig
801803
self._defaults = {spinbox: vars(self._figure.subplotpars)[attr]
802804
for attr, spinbox in self._spinboxes.items()}
805+
self._export_values_dialog = None
803806

804807
def _export_values(self):
805808
# Explicitly round to 3 decimals (which is also the spinbox precision)
806809
# to avoid numbers of the form 0.100...001.
807-
dialog = QtWidgets.QDialog()
810+
self._export_values_dialog = QtWidgets.QDialog()
808811
layout = QtWidgets.QVBoxLayout()
809-
dialog.setLayout(layout)
812+
self._export_values_dialog.setLayout(layout)
810813
text = QtWidgets.QPlainTextEdit()
811814
text.setReadOnly(True)
812815
layout.addWidget(text)
@@ -820,7 +823,7 @@ def _export_values(self):
820823
QtGui.QFontMetrics(text.document().defaultFont())
821824
.size(0, text.toPlainText()).height() + 20)
822825
text.setMaximumSize(size)
823-
dialog.show()
826+
self._export_values_dialog.show()
824827

825828
def _on_value_changed(self):
826829
spinboxes = self._spinboxes

0 commit comments

Comments
 (0)