3 """Define :func:`select_save_file`
11 def select_save_file(directory, name, extension=None, *args, **kwargs):
12 """Get a filename from the user for saving data.
14 1) Prompt the user for a name using `name` as the default.
16 * If the user cancels, return `None`
17 * If the selected name does not exist, return it.
19 2) If the selected name already exists, ask for clobber
22 * If clobbering is ok, return the selected name.
23 * Otherwise, return to (1).
26 return os.path.join(directory, name+extension)
27 def name_exists(name):
28 os.path.exists(path(name))
31 dialog = wx.TextEntryDialog(*args, **kwargs)
33 if dialog.ShowModal() != wx.ID_OK:
35 name = dialog.GetValue()
36 if not name_exists(name):
38 dialogConfirm = wx.MessageDialog(
41 ['A file with this name already exists.',
42 'Do you want to replace it?']),
44 style=wx.YES_NO|wx.ICON_QUESTION|wx.CENTER)
45 if dialogConfirm.ShowModal() == wx.ID_YES: