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.
Display photos and other media
-
Hi. Does anyone know a good way to display photos or video from the iPad Photo app in Pythonista? I have created a folder in Photos but am unsure how to point to it using the Image module. Alternatively, is there a way of storing JPEG’s etc. within Pythonista? It would also be nice to play some sound files. Does anyone have any ideas regarding either of these? Thanks.
-
For reading from and writing to the iOS Photos library, you can use Pythonista's
photos
module. For example you can usephotos.pick_image()
to select a single image using the standard image picker, which is returned as a PIL image. If you want to automatically get all images from an album, you can usephotos.get_albums()
to access the list of albums in your library. Each album has anassets
attribute, which containsAsset
objects for each photo/video in the album. To convert anAsset
to a PIL image, you can use theget_image()
method.You can also manually import assets from the Photos library into Pythonista as files: in the file browser, tap on the "+", then "Import...", then "Photo Library".
For playing sound, Pythonista has a
sound
module. The interface is pretty straightforward, you usesound.play_effect("path/to/sound/file")
to play a file.Pythonista also comes with some built-in sound effects. To use them, tap the "+" button (on iPad it's in the editor toolbar, on iPhone it floats over the keyboard). This brings up Pythonista's media picker. On the "Sounds" tab, you get a list of built-in sound effects. When you select one, its name is inserted into your code as a string, which you can pass to
play_effect
to play that sound. -
It worked. That was very useful. Thank you