# coding: utf-8

# ui.View subclass for the top ten iTunes songs.
# Pull requests gladly accepted.

import feedparser, requests, ui

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 TopTenView(ui.View):
    def __init__(self, image_urls):
        self.present()
        for i, url in enumerate(image_urls):
            button = ui.Button()
            button.background_image = ui.Image.from_data(requests.get(url).content)
            button.border_width = 2
            button.x = (i % 5) * 128 + 10
            button.y = (i / 5) * 128 + 10
            button.width = button.height = 128
            self.add_subview(button)

TopTenView(list(get_image_urls(url)))

@@ -599,32 +599,39 @@
 ent)%0A           
+ w, h =
  button.border_w
@@ -627,23 +627,28 @@
 on.b
-order_width = 2
+ackground_image.size
 %0A   
@@ -671,26 +671,17 @@
 x = 
-(
 i %25 5
-)
  * 
-128 + 10
+w
 %0A   
@@ -704,26 +704,17 @@
 y = 
-(
 i / 5
-)
  * 
-128 + 10
+h
 %0A   
@@ -734,18 +734,17 @@
 on.width
- =
+,
  button.
@@ -756,11 +756,48 @@
 t = 
-128
+w, h%0A            button.border_width = 2
 %0A   

Move to buttons & remove hardcoding of image size