text: Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
  >>>>> "Zunbeltz" == Zunbeltz Izaola <zunbeltz@...> writes:
  Zunbeltz> Hi, I am embeding a matplotlib FigureCanvasWxAgg in a
  Zunbeltz> wxPython program.
  Zunbeltz> When i press the save botton the directory is that of
  Zunbeltz> the executable of the program. I want to change this to
  Zunbeltz> a certain directory. How can i do that?
  There may be an intelligent way to set the default dir globally for file
  dialogs in wx, but I don't know what it is. So I'll suggest a workaround.
  You can create a custom toolbar and override save
  from matplotlib.backends.backend_wx import NavigationToolbar2Wx
  class MyToolbar(class NavigationToolbar2Wx):
  def save(self, evt):
  # Fetch the required filename and file type.
  filetypes = self.canvas._get_imagesave_wildcards()
  # insert your default dir here
  dlg =wx.FileDialog(self._parent, "Save to file", "", "", filetypes,
  wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
  if dlg.ShowModal() == wx.ID_OK:
  dirname = dlg.GetDirectory()
  filename = dlg.GetFilename()
  DEBUG_MSG('Save file dir:%s name:%s' % (dirname, filename), 3, self)
  self.canvas.print_figure(os.path.join(dirname, filename))
  and then use this toolbar rather than the default one. See
  examples/embedding_in_wx4.py for an example of how to use a custom
  toolbar in a wx app.
  JDH
  Hi,
  I am embeding a matplotlib FigureCanvasWxAgg in a wxPython program.
  When i press the save botton the directory is that of the executable of
  the program. I want to change this to a certain directory. How can i do
  that?
  Thanks in advance,
  Zunbeltz
  John Hunter wrote:
  > There may be an intelligent way to set the default dir globally for file
  > dialogs in wx, but I don't know what it is. So I'll suggest a workaround.
  I don't think there isn't. However, it probably starts out in the
  current working directory, which you can change with:
  import os
  os.chdir("ThePathYouWant")
  John's solution is better if this is more than a quickie@...