I’m making a TableView with ListDataSource. Some of the items will have a named image, and some will not. In order to keep the item titles lined up neatly, I’m trying to give the items without images a default transparent image. However, it doesn’t seem to be working.
Here’s roughly what the relevant piece of my code looks like:
# item_list is a list of everything to go on the table
# data_list is a dictionary that will go to ListDataSource
for item in item_list:
if check_for_star(item):
img = ui.Image.named('iob:ios7_star_outline_24')
else:
img = PIL.Image.new('RGBA',(24,24), (255, 255, 255, 0))
data_list.append({'title' : item, 'image' : img})
view['tableview'].data_source = ListDataSource(data_list)
The TableView displays as if the PIL images are None. I thought maybe it needs to be a ui.Image instead, so I tried doing this:
img = ui.Image.from_data(PIL.Image.new('RGBA',(24,24), (255, 255, 255, 0)).toString())
The img variable is still treated like None. Am I missing something? I can use img.show() with the PIL images and they look fine.
In case this helps, here’s an example of what the output looks like. I want all of the title text to line up neatly.
