iewin.IEHtmlWindow shutil.move conflict

T

Todd7

I am writing a python program to load a pdf file into an IEHtmlWindow
which displays it through adobe acrobat reader 7. Depending on the
buttons the user clicks, the program moves it to another subdirectory
with a new name. I am using python 2.4 with wxpython 2.6 on a windowsxp
machine.

I encounter a permission denied error when trying to move the file. It
appears to be caused due to the loading of the pdf file into the
IEHtmlWindow. The program is too long to post here, but below are some
snippets of the code.

self.PDFPanel = iewin.IEHtmlWindow(self, -1, style =
wx.NO_FULL_REPAINT_ON_RESIZE)
....
fileName = 'C:\\test.pdf'

self.PDFPanel.LoadUrl(fileName)

....
# if I do this: self.PDFPanel.Destroy()
# then the following shutil.move works
# else I get a [Errno 13] Permission denied: 'C:\\test.pdf'
# tried loading another pdf file before doing shutil.move
# like: self.PDFPanel.LoadUrl(C:\\Temp.pdf) which loaded fine, but
# I still got a permission denied error

shutil.move(fileName, 'C:\\NewName.pdf')


As stated in the comments above, if I destroy the IEHtmlWindow, then the
move works fine. I do not want to destroy it because I want to continue
using it to load the next pdf file to work on renaming. I tried
self.PDFPanel.LoadUrl('about:blank') before the shutil.move command.
The window displayed a blank screen, but still the permission denied
error. I then tried loading a different pdf file into the window, then
doing the shutil.move on the first pdf, but still the permission denied
error. If I destroy the window before the shutil.move command, then it
works fine, but I need the IEHtmlWindow for other work.

Any suggestions on how to get the IEHtmlWindow to let go of the pdf file
before the shutil.move command without destroying the IEHtmlWindow all
together?

Thanks,
Todd.
 
T

Todd7

Update:
I have found that if I delay the time between when I load a new url into
IEHtmlWindow and then do the shutil.move it works fine. Such as:

self.PDFPanel.Navigate('about:blank') #Must empty pdf frame so file is
not locked
Temp_dlg = wx.MessageDialog(self, 'Waiting for delay',
'Time delay',
wx.OK | wx.ICON_INFORMATION
)
Temp_dlg.ShowModal()
Temp_dlg.Destroy()
shutil.move(fileName, 'C:\\NewName.pdf')

Surely there is a more eloquent way to accomplish this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top