Forum Archive

Creating Own Photo Library?

andallfor

I’m looking to make a game in Pythonista using tons of assets, which I downloaded to the files app on IOS. I’m wondering if I can add a custom photo library, so that whenever I click the “plus” button, I’ll be able to access those photos without having to put them in the current file I’m in.

That is, is it possible to create some similar to “Platformer Art” or “Puzzle Game Art”, and use my own pictures?

Thanks!

cvp

@andallfor Assume you have our own folder MyFolder in iCloud Drive where you store your photos, you can access those photos with path

Path = '/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/MyFolder/photo1.jpg'
andallfor

@cvp
Thanks for the reply!

However, when ever I run it, it returns an error “cannot load texture”.

from scene import * 
Path = '/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/PythonistaProjects/OnScreenControls/transparentDark01.png'

class test(Scene):
    def setup(self):
        self.testIMG = SpriteNode(Path, parent = self, position = (500, 500))

run(test())

I’m not sure if it is something in the code that is wrong, or what.

My images are located in a file called “PythonistaProjects”, and in that file I have another file, called “OnScreenControls”, which contains my pictures. The “transparentDark01’ is the name of the photo that I want to add, and the png is added because the image is a png file. It doesn’t seem to matter if “png” is capitalized or not. The file is located in my iCloud Drive.

mikael

@andallfor, what do you get if you just

open(Path, 'rb')

?

andallfor

@mikael
Thanks for your post, I tried it, but it gave me an error:

PermissionError: [Errno 1] Operation not permitted: '/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/PythonistaProjects/OnScreenControls/transparentDark01.png'
cvp

@andallfor I've created a folder, subfolder and file as you said, in my icloud Drive and your program runs successfully.
But my ipad mini 4 runs under ios 13 and last beta version of Pythomista. Not sure it has an impact, but..

cvp

And .PNG gives an error, thus, please, check names case

And try to open once your folder via external files in Pythonista files browser.

cvp

Only to prove it works