[Twisted-Python] sending images via PB
Robert Gravina
robert at gravina.com
Thu Dec 20 03:50:12 EST 2007
On Dec 20, 2007, at 5:04 PM, Robert Gravina wrote:
> Hi All,
>
> I'm developing an application using Twisted PB, and I'd like to
> send image data from server to client for display there.
>
> Specifically, I'm trying to display an image (e.g. a PNG, but might
> be another type) in a wxPython client which should come from a
> Twisted server somehow, and the client is already connected using PB.
>
> I suppose I can just send the raw file data as a string and use
> that... but just thought I'd ask if anyone has any advice.
>
No worries.. I was able to get it going by just sending the file
contents, i.e.:
#on server, open image
image = open("images/test.png")
data = image.read()
#send data to client
.......
#client side
stream = cStringIO.StringIO(data)
bitmap = BitmapFromImage(ImageFromStream(stream))
wx.StaticBitmap(panel, wx.ID_ANY, bitmap)
Robert
More information about the Twisted-Python
mailing list