1

Well I've been doing a ton of searching and there doesn't seem to be too many people talking about this. With the help of the documentation for wxPython, I've got this far. I'm looking to create a wx.Image widget from an image URL. http://wxpython.org/docs/api/wx-module.html#ImageFromStream

imgStream = urllib2.urlopen(captchaURL).read()
captchaImg = wx.Image(wx.ImageFromStream(wx.InputStream(imgStream)), wx.BITMAP_TYPE_ANY)

Does anybody have some advice for me? Much appreciated.

Oh, the error I'm getting is TypeError: Not a file-like object, with the code snippet above.

2 Answers2

0
buf = urllib2.urlopen(URL).read()
sbuf = StringIO.StringIO(buf)
Image = wx.ImageFromStream(sbuf).ConvertToBitmap()
wx.StaticBitmap(Panel, -1, Image, (10,10))
User
  • 23,729
  • 38
  • 124
  • 207
0
import requests
import io

url = ""
content = requests.get(url).content
io_bytes = io.BytesIO(content)
image = wx.Image(io_bytes).ConvertToBitmap()
staticImage = wx.StaticBitmap(Panel, wx.ID_ANY, image, wx.DefaultPosition, wx.DefaultSize, 0)

replace url and Panel with your url and panel object

naam
  • 471
  • 7
  • 11