[wxPython] Using wxFileSystem on wxPython

Hi all,

I've got the following code:

wxFileSystem_AddHandler(wxInternetFSHandler())
wxFileSystem_AddHandler(wxZipFSHandler())

fs = wxFileSystem()
fs.ChangePathTo(os.getcwd(), 1)

zfile = fs.OpenFile('somefile.zip#zip:foo.txt')

At the end of this, zfile doesn't contain a wxFSFile object like I would
expect. Instead, it has a generic wxObject. I get the same thing for
OpenFile('somefile.zip'). The file system can find the file, because
fs.FindFirst returns the proper filename.

Where's my mistake? This is great stuff, but sometimes it's a little
difficult figuring out how to use it in Python from the C++
documentation. :slight_smile:

Thanks in advance,
-scott

zfile = fs.OpenFile('somefile.zip#zip:foo.txt')

At the end of this, zfile doesn't contain a wxFSFile object like I would
expect. Instead, it has a generic wxObject.

wxFSFile doesn't have the wx type identification stuff set for it, which is
what wxPython's OOR code uses to figure out what kind of Python object to
create. I'll fix it for the next release.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

OK, thanks.

In the meantime, does this mean that I need to find alternate means? :slight_smile:
Without the identification, the object that is returned doesn't have the
GetStream method.

Thanks,
-scott

Robin Dunn wrote:

···

>
> zfile = fs.OpenFile('somefile.zip#zip:foo.txt')
>
> At the end of this, zfile doesn't contain a wxFSFile object like I would
> expect. Instead, it has a generic wxObject.

wxFSFile doesn't have the wx type identification stuff set for it, which is
what wxPython's OOR code uses to figure out what kind of Python object to
create. I'll fix it for the next release.

In the meantime, does this mean that I need to find alternate means? :slight_smile:
Without the identification, the object that is returned doesn't have the
GetStream method.

wxPyTypeCast should work. (See wx.py and the archive for this list for
notes about it.)

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

Excellent, that worked. Thanks muchly.

Regards,
-scott

Robin Dunn wrote:

···

wxPyTypeCast should work. (See wx.py and the archive for this list for
notes about it.)

Hi, I read in the archives that this functionality is on Robin's TODO
list; any idea of an ETA?

Should I just unzip my .zip files and load things from the filesystem
for now, or wait?

Thanks,
-scott

Hi, I read in the archives that this functionality is on Robin's TODO
list; any idea of an ETA?

It's on my list for the next release, but I don't know when that is yet.

Should I just unzip my .zip files and load things from the filesystem
for now, or wait?

Encapsulate it in a getImage(name) function and then it will be easy to
change later.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!