Hello again. I recently received some great help on how to a group of url images to a view. It works perfectly.
Here's the code
import feedparser, ui, Image, requests
from urllib2 import urlopen
from io import BytesIO
url = 'https://itunes.apple.com/us/rss/topsongs/limit=10/xml'
def get_image_urls(itunes_url):
for entry in feedparser.parse(itunes_url).entries:
yield entry['summary'].partition('src="')[2].partition('"')[0]
class AlbumView(ui.View):
def __init__(self, image_urls):
#self.present()
for i, url in enumerate(image_urls):
#new code
img = Image.open(BytesIO(urlopen(url)).read())
button.ui.Button()
button.image = img
#old code
'''
image_view = ui.ImageView()
image_view.load_from_url(url)
self.add_subview(image_view)
image_view.x = (i % 5) * 128 + 10
image_view.y = (i / 5) * 128 + 10
'''
AlbumView(get_image_urls(url))
But what I want to do is instead of a plain image I want each URL image to be a button. ( the url image is used as the button image).
I used BytesIO but I get an error that it's returning an instance not an ImageI'm having a hard time converting to url image to a ui.Image , which the button image field takes.
Thanks