[Twisted-Python] sending images via PB

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. Robert

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

On Thu, 20 Dec 2007 17:50:12 +0900, Robert Gravina <robert@gravina.com> wrote:
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
For potentially large files, you might want to use FilePager from twisted.spread.util, if you aren't already. Jean-Paul
participants (2)
-
Jean-Paul Calderone
-
Robert Gravina