I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.
How can I make FileDialog just select the file and return the path and file
name without trying to access the file?
The command I am currently using:
open_dlg = wx.FileDialog(self, message=message, defaultDir=open_dir,
defaultFile=default_file,
wildcard=wcd, style=wx.OPEN|wx.CHANGE_DIR)
I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.
How can I make FileDialog just select the file and return the path and file
name without trying to access the file?
I'm not sure there is a solution to this problem. I believe the
underlying Windows API (GetOpenFileName) tries to verify that you have
permission to open the file, and that operation won't work if the file
is opened exclusively by someone else
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
If the files is opened exclusively and permanently by the Database then there is no point in allowing the user to select it as they will not be able to use it.
···
On 16/07/13 18:30, Tim Roberts wrote:
swiper wrote:
I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.
How can I make FileDialog just select the file and return the path and file
name without trying to access the file?
I'm not sure there is a solution to this problem. I believe the
underlying Windows API (GetOpenFileName) tries to verify that you have
permission to open the file, and that operation won't work if the file
is opened exclusively by someone else
BTW, on Windows the other program can be the preview window in Explorer - it doesn't seem to release file handles until I don't know when - probably to speed up the next access which might never happen.
Werner
···
On 16/07/2013 08:38, swiper wrote:
I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.
actually write any code that would clobber the file once it's selected!)?
Then you could use this style:
wx.FD_OVERWRITE_PROMPT For save dialog only: prompt for a confirmation
if a file will be overwritten.
···
On Mon, Jul 15, 2013 at 11:38 PM, swiper <drcsturm@gmail.com> wrote:
I would like to use the FileDialog to allow the user to select the location
of a database file which will be used in the program.
The database is used at the same time by another program and this other
program is always on.
When FileDialog is ran and the database file is selected and the Open
button
pressed a message appears:
"File in use." and I am not able to select the file. The file is in use by
another program but I just want to get the path and filename.
How can I make FileDialog just select the file and return the path and file
name without trying to access the file?
The command I am currently using:
open_dlg = wx.FileDialog(self, message=message,
defaultDir=open_dir,
defaultFile=default_file,
wildcard=wcd, style=wx.OPEN|wx.CHANGE_DIR)
Thanks
What if you use a Save dialog instead (being careful, of course, not to
Thanks for the feedback.
I am interested in having the user select a file that is in use by a different program so I can store the file location for later use when the file is not open else where.
So I need the user to specify the file location regardless of the file being open.
I used Marc’s suggestion of changing from wx.OPEN to wx.SAVE. That worked for me. I didn’t use the wx.FD_OVERWRITE_PROMPT because the file already exists and when selected the warning box pops up.
I am not immediately writing to the file so that is not a concern for me.
I was hoping to keep the open option because open is more intuitive but save works for now.
Thanks for all your help. It was very useful.
···
On Tue, Jul 16, 2013 at 4:13 PM, Marc Tompkins [via wxPython-users] <[hidden email]> wrote:
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
What if you use a Save dialog instead (being careful, of course, not
to actually write any code that would clobber the file once it's
selected!)?
Then you could use this style:
wx.FD_OVERWRITE_PROMPT For save dialog only: prompt for a
confirmation if a file will be overwritten.
That will have the same problem. The File Save Dialog checks to see
that the file is writable by you.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.