[wxPython] wxInputStream

Hi. There’s three issues here.

One is that “wxFileSystem.OpenFile” returns a wxObject instead of a wxFile. There’s a work around shown below.

Two is that I have no idea how to load a bitmap from bits. There’s no documentation anywhere and I don’t understand the error message: “argument 1 must be string without null bytes, not str”

How can it expect bitmap data with no null bytes!? And what’s the difference between ‘str’ and ‘string’ types?

BTW: This is using a gif, I’ve tried it with a bmp too with the same results.

Finally wxImage doesn’t support anything to do with wxInputStream, not the constructor nor the LoadFile (takes a filename instead). Is there a way around this? Is it long term? Thanks :slight_smile:

Please help
Thanks heaps
Matthew Sherborne

from wxPython.wx import *
wxInitAllImageHandlers()
wxFileSystem_AddHandler(wxZipFSHandler())
sys=wxFileSystem()
sys.OpenFile(‘resources.zip#zip:images/hand2.gif’)

f=_
f.GetStream()
Traceback (most recent call last):
File “”, line 1, in ?
AttributeError: wxObjectPtr instance has no attribute ‘GetStream’
wxPyTypeCast(f, ‘wxFSFile’)

f=_
f.GetStream()

stream = _
stream.read()
‘GIF89a?\x00.\x00\xf7\x00\x00\x08\x00\x00\x10\x00\x00\x10\x00\x08\x10\x08\x00\x10\x08\x08\x10\x08\x10\x10\x10\x08\x10\x10\x10\x18\x00\x00\x18\x04\x04\x18\x08\x08\x18\x08\x10\x18\x10\x08!\x00\x00#\x08\x08)\x10\x08\x18\x10\x10\x18\x10\x18!\x10\x10!\x10\x18)\x04\x10)\x10\x10)\x10\x18!\x10!\x18\x18\x10!\x18\x10\x18\x18\x18!\x18\x18!\x18!&\x1e\x18&\x1e!)!)4\x0e\x0bD\r\x08Q\x0f\x08N!\x101\x18\x1c1!)<!#L\x1b\x18]\x18\x06^!\x10R!\x18Z!\x18R)\x18Z)\x10Z)\x18c%\x14))%1)!1))5)-B-)Z)!Z1!c)\x181119)1?.1J11=97N9:PHGXRUk#\x12k)\x18c)!c1\x1cp&\x1bk1\x18w-\x18{)!k1!h6)s1!k=){9\x18s9!w3's?.{9%\x861"~B#\x849-\x84B){B1\x7fF-\x81L/\x8c?'\x8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xce\xc6\xc6\xd2\xca\xbd\xd6\xc6\xc6\xd6\xce\xbd\xce\xce\xc6\xd6\xce\xc6\xce\xce\xce\xd6\xce\xce\xd6\xd6\xc6\xd6\xd6\xce\xd6\xd6\xd6\xde\xc6\xbd\xde\xce\xc1\xde\xce\xce\xde\xd6\xbd\xde\xd6\xc6\xe7\xce\xbd\xe9\xd3\xc3\xef\xd6\xc1\xde\xd6\xce\xde\xd6\xd6\xde\xde\xc6\xde\xde\xce\xe7\xd6\xce\xeb\xde\xc6\xe7\xd6\xd6\xeb\xde\xce\xde\xde\xd6\xde\xde\xde\xe7\xde\xd6\xe7\xde\xde\xe7\xe7\xce\xe7\xe7\xd6\xe7\xe7\xde\xef\xde\xda\xef\xe7\xd6\xef\xe7\xde\xef\xef\xde\xf7\xde\xce\xf7\xde\xd6\xf7\xe7\xd6\xf7\xe7\xde\xf7\xef\xde\xe7\xe7\xe7\xef\xe7\xe7\xef\xef\xe7\xef\xf7\xe7\xf7\xe7\xe7\xf7\xef\xe7\xf7\xf7\xe7\xef\xef\xef\xf7\xef\xef\xf7\xf7\xef\xff\xef\xef\xff\xf7\xef\xf7\xf7\xf7\xff\xf7\xf7\xff\xff\xf7\xff\xff\xff!\xf9\x04\x01\x00\x00\xff\x00,\x00\x00\x00\x00?\x00.\x00\x00\x08\xfe\x00\xff\t\x1cH\xb0\xa0\xc1\x83\x08\r\xd6cU*\x91+P\xaf\n\xf5A\xc4\x88\xd4\xb7\x84\x183j\xfc\x97\x8fT+R\x1e]1\x1a\xa9\x88\xd1 <j\xdc\x88\xa9\xa3g\x90\x9e>y\n\x19\xdaH\x13c\x9f>\xaf\xf0\xf0\x99\xa8G\x0e\x1d9n\xe0\xb8I\x13f\x8b\x960i\xc6\x90Qz&\x8d\x1f?\xe7jJ\x15\xd8\xe7\x8e\x1e>\x8a\x10\xf59C\xa6K\x17-Q\xa0\x181\xe2$\x88\x12(P\xceB\xa1\x12%J\x1a1b\xa6\xd6\xbc9\xa8\x8f"E\x89\^9r\xc4\xc8\x11 /\x02\x07\t\x82\xc4\tZ$\x88\x89\xf0\xc5"W#\xad>z\xae\x1e*%\x92Q\xa2D\xa3\xd0<\x013\xa6K\rM\x03\xfb\xf1\xeb\xd7\xaf\x8d\x13'\x85\x1bg\x8c\x1cy\x10\x9fA\x88V=\xea\xf3\x07\x94"P\xa0\xae\xba\xb4C\x88\x8f\xea\xc6z\xec\xb0\x8e\x9cg\x0e\x1c-\xc8\xc5\xac\xa9#GN\x1d\xa1\xce\xe9\xe0\xf9]\xf3[\x9d:\xc2Y\xd6\xc1\xf3\x05\x8b\x11%T\xc0\xfep\xf1\xda%L\x98\xf2c\x9c\xbb1F]#\x9f\xebn\xea\xc4\x89\x0f'\xcc\x94&A\x9cp\xe1B\x051\xe2&M\x9c\x86\x16\x15c\xb4\x87\x11vu\xd0\x11\x07sq\x90\xd1U\x17cD\xe8\xc6\x19g\\x01\xc2\t*\xac \x04\x12\x01&\xe1\x04\x18\x06\x1et\x0e\x82q\xcc\xf7\x93\x17aH\xe8F\x1c'\x01\xe5\xc6Oc,\x01\xc2\x03\x15\x9c\x80\xc4f!\x16\x14\x1c\x1d\xf2\xbd\xe8\x86\x19n\x9c7\x06\x17RtA\x87\x1du\xcc\x81G\x90c\xb8\xb1\xc6\x19c<!\x04\x0b\x1fR\xf7\x03\r4\x08\x84\x8f<v\xd8\xc1#\x1f%\xc2\x01\xa5\x1bCJA\x05\x15^\x9c\xb1\x85w^EH^yhd\xd1\x85\\x97\xe8\xc0\x83\x0e3\xe0\x19\x039\xf2\xf4)\x0f\x8f/\xd6Aa\x1ccd\xc1\x85yc\x84\x81\x85\x12A\x14\xd1\x04\x15OD\x1a\xa0aU\x80\xe1\x15Fm\xe09\xc3\x0c%\xcc \x83\xa7%\xc40\x03\x0c%\x94\x82<\xe9\xf4YG|q4EG\x18\xfehvA\x06\x7fT\xc8I\x05\x80\x88\xd5p\x03\x12\xbb\x02\xe8\xc4\x11\xe1\xaa)\xa7\xa5\x92Zj\xb11\x94\x8e:\xa9\x12"\xa8P\x84\x1a\xca\x1f\x14M\xac\x05a\x1aCYX\xc1\x85\'\x8c\xb0\xc2\x0b\x86e\xd4F\t0x\xe0\x01\x0c\xe5\x16k\xae\xb9%x\xf0\x8c9\xe90{\x06\xb4\x85\x8e\x17\x06\x8a]\xec\xa7D\x13\\\x9c\xd1\x1c\x1ev\xf0\xf1\x1ePa8\xa1Q\x1b0t.\xa9\n\x93\xcan\xb90 @\xce8\xde\x98\xe3\x86\x93^@\xf1\x84\xa1h\x84a\x86R\xb0\xea\x87\x1c\x16\xfd\nu\xf1\xc5u\x1c\xec\x01\x07\x1d4|\xee\xb9\xed\xb6\xbc.6\xd1p\xe3\xcd'\x85Z!\xc5\xc6R@!\xc5\x15^\xd1J\x85b\x1c"1 \x15\xf6\xaa\xacp\t\n7\xdd\x01\x07+C\xadp3\xce4\xc3\xcd6\x9dq\xf1D\x13\x1c\x06X\x04b[\x13\xe6_\x13K\xe0\n\x13Q\xa8\xcc\xb2\x072+\xbc\xae\xdblC\xd2L3\xe4\x90\xd3\x05\xb5\xff\x15\x8d\xc4\xfe\n.\xd4\xe0B\x11I,\x11i\xcf\xa79\x11)\x14\x1b\xb5\x013\x07P\xbf\xed\x01\xa7l\x9b\x8b\x0025o\x03\xc6\r.\xb8p\x03\xe6\x98\xf7\xbd+\x87\x91\x9eYk\x16\xa4S\x91\x0fMm<\xcd\xc1\x06-\xb7\x0eA\xcb,?\xdd21\xca\xd3\xcc6'\xb0\xc0\x82\x0bd\xaek\rH\xd8\x80\x98\x13;S\xd7\x06\xeb\x1a\xb4\xbc\xc1\xf2,/\xef<\xeb\x12 \x93\x0c1\xc4d\x12\xc2\x08\xbd\xf7\xad=\xf0K\x10\x8fx{\xa9w\xb0\x81\x06\xabw@>\xe3\xb2\xcb\xbe\x01%\x9f\x18CL3\x19\xfa\x9d9b\x817!\x05 9\xb6\xa1\x81\x06\xe3s\xa0\xc1\xeb\xff[\x1e\xffZ\x075b\x18\x03\x19\xc6\xb0\x84\x0b\x90\x00<\xc4t\xef\t9\x1aH\x1b \xf0\xbf\xfd\x8d\xaf\x03\x18\x9d\xf3\x94\xe7?NP\xaf\x13\x95\xb8\x81\xf0\x90\xb0\x84%\xb4!\x82\x04\x99 \x04V\xc8B\xd6\xadnu.T\xdd%2q\x897\xb0\x81\x81H\x00\r\n\x0b\xa2\xc2\xe5\xb5\x90\x82\xde\xe3s\x1e\x04.H\tI\xb4\xe1\x88;L\x88\n!\xe0\xbf\r\xac\x90\x7f\xfc{\x1d\x0c\xf9\xc7\x036X1XI<\xc8\x12!\x80\x01\x16\xfe\xaf\x8b\x14\x0c\xe3\xf2\x0c\x00\x06sdQ\x89,\x0cc\x1a\xff\xf7D\nV\xf0\x8c\x98J\xa3\x1c\xdb\xe8E\x16\xc2\x11\x8ds\xcc\xe3\x1c\xef\x88\x90-\xeaQ\x8f|\xd4"\x04\x0e\xf0G9\x12r\x85\x91\x08$\x0fYx\xc8\x15\x1a\x85\x12\x18$\x04\x1e\x99FE\xa6\xf0\x8f\x91\x9c\xa4\x01\x1eII\x08H\xc0\x92\x12\x1c\xe4\x01\x18@\xc9N\xa6Q\x01\x90\xf4$(\x05\xd2\x06\x03(@\x01\x99\x9c\xe3\x06$\x80\x010\x86q\x95\xff\x98 !c\xc9EZJ\xc0\x89>t\xa2\x04>\xb9J\x15n\xb2\x85\xbf\x84\xe5&\x8f\x08\tHP\x82\x12\xf7\xc0\xa5\x1f\x1d\xf9\xc9h\xe2\x12\x8f\x10\x10\x00\x0c\xae9\x15~ps\x01\x01\x00;’
data = _
wxBitmapFromBits(data, 63, 46)
Traceback (most recent call last):
File “”, line 1, in ?
File “C:\Python22\Lib\site-packages\wxPython\gdi.py”, line 1311, in wxBitmapFromBits
val = apply(gdic.wxBitmapFromBits,_args,_kwargs)
TypeError: wxBitmapFromBits() argument 1 must be string without null bytes, not str

Hi. There's three issues here.

One is that "wxFileSystem.OpenFile" returns a wxObject
instead of a wxFile. There's a work around shown below.

Already fixed in CVS.

Two is that I have no idea how to load a bitmap from bits.
There's no documentation anywhere and I don't understand
the error message: "argument 1 must be string without null
bytes, not str"

This may be an issue with the SWIG type checking. I'll take a look.
Regardless, bits is not the binary data for an image file as you've tried,
but litterally an array of bits...

Finally wxImage doesn't support anything to do with
wxInputStream, not the constructor nor the LoadFile
(takes a filename instead). Is there a way around this?
Is it long term? Thanks :slight_smile:

Already fixed in CVS. Please take a look at the 2.3.3 preview.

···

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

Thanks Robin. :slight_smile:

Good work. You made me a happy chappy. :smiley:

GBU
Matthew Sherborne

···

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Saturday, June 08, 2002 3:50 AM
Subject: Re: [wxPython] wxInputStream

> Hi. There's three issues here.
>
> One is that "wxFileSystem.OpenFile" returns a wxObject
> instead of a wxFile. There's a work around shown below.

Already fixed in CVS.

> Two is that I have no idea how to load a bitmap from bits.
> There's no documentation anywhere and I don't understand
> the error message: "argument 1 must be string without null
> bytes, not str"

This may be an issue with the SWIG type checking. I'll take a look.
Regardless, bits is not the binary data for an image file as you've tried,
but litterally an array of bits...

> Finally wxImage doesn't support anything to do with
> wxInputStream, not the constructor nor the LoadFile
> (takes a filename instead). Is there a way around this?
> Is it long term? Thanks :slight_smile:

Already fixed in CVS. Please take a look at the 2.3.3 preview.

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users