Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67de499

Browse files
authored
Merge pull request #21187 from anntzer/error_msg
MNT: Deprecate error_msg_foo helpers.
2 parents de64d0b + 1b908e3 commit 67de499

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``backend_gtk3.error_msg_gtk`` and ``backend_wx.error_msg_wx``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated.

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ def on_notify_filter(*args):
526526
try:
527527
self.canvas.figure.savefig(fname, format=fmt)
528528
except Exception as e:
529-
error_msg_gtk(str(e), parent=self)
529+
dialog = Gtk.MessageDialog(
530+
parent=self.canvas.get_toplevel(), message_format=str(e),
531+
type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK)
532+
dialog.run()
533+
dialog.destroy()
530534

531535

532536
class ToolbarGTK3(ToolContainerBase, Gtk.Box):
@@ -722,6 +726,7 @@ def trigger(self, *args, **kwargs):
722726
clipboard.set_image(pb)
723727

724728

729+
@_api.deprecated("3.6")
725730
def error_msg_gtk(msg, parent=None):
726731
if parent is not None: # find the toplevel Gtk.Window
727732
parent = parent.get_toplevel()

lib/matplotlib/backends/backend_wx.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class __getattr__:
5656
}))
5757

5858

59+
@_api.deprecated("3.6")
5960
def error_msg_wx(msg, parent=None):
6061
"""Signal an error condition with a popup error dialog."""
6162
dialog = wx.MessageDialog(parent=parent,
@@ -1153,15 +1154,15 @@ def save_figure(self, *args):
11531154
# Fetch the required filename and file type.
11541155
filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
11551156
default_file = self.canvas.get_default_filename()
1156-
dlg = wx.FileDialog(
1157+
dialog = wx.FileDialog(
11571158
self.canvas.GetParent(), "Save to file",
11581159
mpl.rcParams["savefig.directory"], default_file, filetypes,
11591160
wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
1160-
dlg.SetFilterIndex(filter_index)
1161-
if dlg.ShowModal() == wx.ID_OK:
1162-
path = pathlib.Path(dlg.GetPath())
1161+
dialog.SetFilterIndex(filter_index)
1162+
if dialog.ShowModal() == wx.ID_OK:
1163+
path = pathlib.Path(dialog.GetPath())
11631164
_log.debug('%s - Save file path: %s', type(self), path)
1164-
fmt = exts[dlg.GetFilterIndex()]
1165+
fmt = exts[dialog.GetFilterIndex()]
11651166
ext = path.suffix[1:]
11661167
if ext in self.canvas.get_supported_filetypes() and fmt != ext:
11671168
# looks like they forgot to set the image type drop
@@ -1176,7 +1177,11 @@ def save_figure(self, *args):
11761177
try:
11771178
self.canvas.figure.savefig(str(path), format=fmt)
11781179
except Exception as e:
1179-
error_msg_wx(str(e))
1180+
dialog = wx.MessageDialog(
1181+
parent=self.canvas.GetParent(), message=str(e),
1182+
caption='Matplotlib error')
1183+
dialog.ShowModal()
1184+
dialog.Destroy()
11801185

11811186
def draw_rubberband(self, event, x0, y0, x1, y1):
11821187
height = self.canvas.figure.bbox.height

0 commit comments

Comments
 (0)