Work directory is changed when saving a plot

Hi,

When I save a plot using the toolbar save function, and I save to a different directory than the one where my program is, my program can no longer locate the icons (used in my GUI) that I am using in my .\ressources directory. So saving the plot changed the working directory of my program?

How do I change it back? Isn’t this an error in matplotlib?

Thanks
Soren

Which backend are you using? I don't see any explicit calls to chdir in matplotlib that would make this happen. It would certainly be unintentional if it is.

Mike

S�ren Nielsen wrote:

···

Hi,

When I save a plot using the toolbar save function, and I save to a different directory than the one where my program is, my program can no longer locate the icons (used in my GUI) that I am using in my .\ressources directory. So saving the plot changed the working directory of my program?

How do I change it back? Isn't this an error in matplotlib?

Thanks
Soren
------------------------------------------------------------------------

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Michael Droettboom wrote:

Which backend are you using? I don't see any explicit calls to chdir in matplotlib that would make this happen. It would certainly be unintentional if it is.

I don't know about any other back-ends, but the wx FileDialog has an option to change the working dir when the user selects a file I also don't know if this flag is set in the MPL code, but it shouldn't be.

Søren Nielsen wrote:

my program can no longer locate the icons (used in my GUI) that I am using in my .\ressources directory. So saving the plot changed the working directory of my program?

How do I change it back? Isn't this an error in matplotlib?

I'd say yes, but it's also an error in the design of your code -- as you've discovered, the working dir is a tenuous concept -- you should set that resources dir in your code start-up and keep it around for when you need it.

wxPython has wx.StandardPaths which can be helpful for finding your aps data, etc -- I'm sure the other toolkits have something, too.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...