iewin.IEHtmlWindow shutil.move conflict

Todd7 nospam at
Wed Dec 7 19:20:17 CET 2005

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
shutil.move(fileName, 'C:\\NewName.pdf')

Surely there is a more eloquent way to accomplish this?

Todd7 <nospam at> wrote in news:YUslf.74898$2k5.73363

> 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 
> machine.
> I encounter a permission denied error when trying to move the file.  
> 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 
> snippets of the code.
> self.PDFPanel = iewin.IEHtmlWindow(self, -1, style = 
> ...
> 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 
> move works fine.  I do not want to destroy it because I want to 
> 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, 
> doing the shutil.move on the first pdf, but still the permission 
> error.  If I destroy the window before the shutil.move command, then 
> works fine, but I need the IEHtmlWindow for other work.
> Any suggestions on how to get the IEHtmlWindow to let go of the pdf 
> before the shutil.move command without destroying the IEHtmlWindow all 
> together?
> Thanks,
> Todd.

More information about the Python-list mailing list