@@ -339,7 +339,7 @@ def __init__(self, canvas):
339
339
def save_figure (self , * args ):
340
340
dialog = Gtk .FileChooserDialog (
341
341
title = "Save the figure" ,
342
- parent = self .canvas .get_toplevel (),
342
+ transient_for = self .canvas .get_toplevel (),
343
343
action = Gtk .FileChooserAction .SAVE ,
344
344
buttons = (Gtk .STOCK_CANCEL , Gtk .ResponseType .CANCEL ,
345
345
Gtk .STOCK_SAVE , Gtk .ResponseType .OK ),
@@ -371,16 +371,17 @@ def on_notify_filter(*args):
371
371
fmt = self .canvas .get_supported_filetypes_grouped ()[ff .get_name ()][0 ]
372
372
dialog .destroy ()
373
373
if response != Gtk .ResponseType .OK :
374
- return
374
+ return None
375
375
# Save dir for next time, unless empty str (which means use cwd).
376
376
if mpl .rcParams ['savefig.directory' ]:
377
377
mpl .rcParams ['savefig.directory' ] = os .path .dirname (fname )
378
378
try :
379
379
self .canvas .figure .savefig (fname , format = fmt )
380
+ return fname
380
381
except Exception as e :
381
382
dialog = Gtk .MessageDialog (
382
- parent = self .canvas .get_toplevel (), message_format = str (e ),
383
- type = Gtk .MessageType .ERROR , buttons = Gtk .ButtonsType .OK )
383
+ transient_for = self .canvas .get_toplevel (), text = str (e ),
384
+ message_type = Gtk .MessageType .ERROR , buttons = Gtk .ButtonsType .OK )
384
385
dialog .run ()
385
386
dialog .destroy ()
386
387
0 commit comments