From: Kevin A. <al...@se...> - 2004-11-10 18:52:37
|
On Nov 10, 2004, at 5:46 AM, Schollnick, Benjamin wrote: > Folks, > > I am attempting to do two things: > > 1) Access a virtual file system containing the contents of a ZIP > file. This has been achieved, via using the VFS / ZipFS from skunkWeb. > > 2) Use a HTML Window component to view the HTML contents.... > This is partially usable... But there is several major issues. > > > The issues are: > > 1) [Minor] HTML Window is not frames enabled... > 2) The following code works okay... > > self.directory, self.zip_filename = self.Choose_Zip_File ( ) > self.directory = self.directory + os.sep > print self.directory > print self.zip_filename > self.zipfile = zipfs.ZipFS ( self.directory + self.zip_filename > ) > open = self.zipfile.open > > if self.zipfile.isfile ("default.htm"): > tempfile = self.zipfile.open (r"default.htm") > text = "".join (tempfile.readlines () ) > > self.components.BookViewer.text = "".join > (tempfile.readlines()) > > But the HTML Window does not properly display the graphics, nor > can it navigate the HTML file. Any links that are clicked are > "broken"... > > So I suspect the WX HTML viewer does not use the Python Open > command... Since I re-assigned OPEN to the zipfile open routines... > > Any suggestions on working around this? I can deal with the > lack of > frames.... But I really need to be able to view the graphics, > and > follow the links... > > > - Benjamin > IEHtmlWindow (Windows-only) would support frames, HtmlWindow doesn't; see the readme.txt or wxPython documentation for more info on which attributes it supports. In order for HtmlWindow or IEHtmlWindow to open images or follow links within the HTML, it must have absolute or relative URLs that it can find via an http: or file: URL. wxPython wraps wxWidgets, so the underlying control doesn't use Python's open command. I suspect the only way you would be able to get this to work would be to unzip the contents into a temporary directory. Pass the absolute path of the file (self.components.BookViewer.text = 'default.htm') for the starting point. If you don't do a chdir to the directory beforehand, use an absolute path. If there is another workaround for the underlying HtmlWindow control, you'll need to ask about that on the wxPython-users mailing list. There might actually be a way of overriding some internal methods to just fetch the contents of the zip file as needed. In fact, since there is a Help Viewer (HtmlHelpController) that already uses zip files it might be that the trick is to override LoadPage. You would need to modify your htmlwindow.py component module or make a custom one for your app and do the appropriate LoadPage override. Again, ask on wxPython-users what you need to do to make it work. ka |