Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
TableView with imported picture
-
Hi everybody!
First I imported a 256px by 256px JPG-Picture to "My Images" (_Image_5) and then I tried to show it in an ui.TableView (title: 'no image1' and 'no image2'), but I can see only the text. Any ideas?import ui v = ui.View() v.background_color = 'white' v.name = 'acessory_types:' chs = ui.TableView() lst = ui.ListDataSource([{'title':'none','accessory_type':'none'},{'title':'checkmark','accessory_type':'checkmark'},{'title':'detail_button','accessory_type':'detail_button'},{'title':'detail_disclosure_button','accessory_type':'detail_disclosure_button'},{'title':'disclosure_indicator','accessory_type':'disclosure_indicator'},{'title':'image24 and checkmark','image':'ionicons-images-24','accessory_type':'checkmark'},{'title':'image32','image':'ionicons-alert-32'},{'title':'image256','image':'ionicons-alert-circled-256'},{'title':'frog','image':'Frog_Face'},{'title':'no image1','image':'_Image_5'},{'title':'no image2','image':'_Image_5.jpg'}]) chs.data_source = lst chs.delegate = lst chs.frame = (5,5,504,504) v.add_subview(chs) v.present('sheet')
-
Hi,
I had a similar problem and Ole - as always - had the solution. Try this:
import ui, os v = ui.View() v.background_color = 'white' v.name = 'acessory_types:' images_root = os.path.expanduser('~/Documents/Images') image_name = '_Image_5' image_path = os.path.join(images_root, image_name + '.png') chs = ui.TableView() lst = ui.ListDataSource([{'title':'none','accessory_type':'none'},{'title':'checkmark','accessory_type':'checkmark'},{'title':'detail_button','accessory_type':'detail_button'},{'title':'detail_disclosure_button','accessory_type':'detail_disclosure_button'},{'title':'disclosure_indicator','accessory_type':'disclosure_indicator'},{'title':'image24 and checkmark','image':'ionicons-images-24','accessory_type':'checkmark'},{'title':'image32','image':'ionicons-alert-32'},{'title':'image256','image':'ionicons-alert-circled-256'},{'title':'frog','image':'Frog_Face'},{'title':'no image1','image':image_path},{'title':'no image2','image':image_path}]) chs.data_source = lst chs.delegate = lst chs.frame = (5,5,504,504) v.add_subview(chs) v.present('sheet')
-
Looks like you may need the full path to the image. For example, I had a random image in the main folder (i.e available from top folder in editor) called cave.jpg.
'image':os.path.expanduser('~/Documents/cave.jpg'
worked. If you created a my images folder, you'll have to add that after Documents above.
You can test it by
ui.Image.named(yourname)
, the check size. -
Great, thank you both very much.
I noticed ...
My Images => /Images (hidden in /Documents)<br>
Imported Image => ~/Documents/Images/name.png (Image from clipboard is added as PNG)<br>
Reachable with the full path or from /Documents via 'Images/name.png'