I've been using this to initialize my working directory:
(1) os.chdir(wx.StandardPaths.Get().GetDocumentsDir())
and this for my file dialogs:
(2) dlg = wx.FileDialog(self, "Select Input File", os.getcwd(), "",
style=wx.OPEN|wx.CHANGE_DIR)
This works fine on windows and linux, but on mac the wx.CHANGE_DIR
doesn't work (the working directory doesn't change). I'm using Python
2.5 and the most recent version of wxPython.
If I change the above to:
(3) dlg = wx.FileDialog(self, "Select Input File", "", "",
style=wx.OPEN|wx.CHANGE_DIR)
Then it works on all platforms except that the initialization of the
working directory from (1) above doesn't work. Just before the first
call to wx.FileDialog, os.getcwd() gives the right value, but the file
dialog starts in a different directory. After the first call to
wx.FileDialog, everything is fine.
This is such a basic operation, that I wouldn't think there would be
any bugs. Could someone please enlighten me as to what I am doing
wrong?
Jeff
Jeffrey O'Neill wrote:
This is such a basic operation,
Well, sort of. Except that the concept of a "working directory" is kind of foreign to the Mac -- at least with GUI apps, and doesn't really make a lot of sense for other GUI apps either, on Windows or Linux -- what should the working dir be when an app is started by clicking an icon?
My suggestion os not to count on, or change, the working directory, but rather to keep track of what directory is appropriate for your app for a particular purpose.
wx.StandardPaths can get you the basic paths you might need: notably wx.StandardPaths.GetDocumentsDir()
In other situations you may want to open a file dialog set to the last path the user used, or the same path as the current docs , or ???, so keep track of these in your app and you're all set.
-CHB
ยทยทยท
--
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@noaa.gov