Pythonista-Issues
Pythonista-Issues copied to clipboard
Pythonista hangs on opening Photo Library
Hi,
i am using Pytonista on an Iphone 15 Pro (iOS 17.2.1) and Pythonista 3.4.
On a older Iphone XS (iOS 17.2.1) everything works fine. But on the new Iphone if i just press the Button form the UI. The Iphone App hangs a lot.
I i just run the "photos.pick_asset". It works fine. Could it be a problem with the Popup Function?
In the UI Script there is just a button which start the launchimg() function.
BR kami
import ui import photos
def launchimg(sender): assets = photos.pick_asset(assets=photos.get_assets(media_type='image'),title='Select Image2', multi=True) print (assets)
assets = photos.pick_asset(assets=photos.get_assets(media_type='image'),title='Select Image1', multi=True) print (assets)
v= ui.load_view('image') v.present()
How long does assets=photos.get_assets(media_type='image') take to run?
30sec - 60secs and more. But it is also the same problem if i run "assets = photos.capture_image()"
Does the following work if you leave out all of the ui code?
import photos
def launch_img(sender):
print("Calling photos.get_assets(media_type='image')...")
assets = photos.get_assets(media_type='image')
print(f"{len(assets)} images found. -- Calling photos.pick_asset()")
assets = photos.pick_asset(assets, title='Select images', multi=True)
print(f"{len(assets)} images selected.")
if __name__ == "__main__":
launch_img(None)
If not, does multi=False change things?
Hi, works fine with both True and False. The hanging just starts if i use a Button.
Cool... So first get the images from the user and then once that is finished you can do the ui work.
import photos
import ui
def launch_img(sender):
print("Calling photos.get_assets(media_type='image')...")
assets = photos.get_assets(media_type='image')
print(f"{len(assets)} images found. -- Calling photos.pick_asset()")
assets = photos.pick_asset(assets, title='Select images', multi=True)
print(f"{len(assets)} images selected.")
return assets
if __name__ == "__main__":
assets = launch_img(None)
if assets:
view = ui.load_view('image')
view.present()
No, sorry that is just a small example for the problem. The main app is much bigger and in this app i need to use a button. So the problem should be somewhere else. Because on my older iphone it is no Problem.
BR kami
You probably need the @ui.in_background function decorator somewhere in your code as discussed at:
- https://omz-software.com/pythonista/docs-3.4/py3/ios/ui.html#about-actions-and-delegates
Hi, if i put @ui.in_background before every function it works fine. But why do i need this now and not in the past? Can i fix it any way else. Maybe globally?
BR kami
You probably need the
@ui.in_backgroundfunction decorator somewhere in your code as discussed at:* https://omz-software.com/pythonista/docs-3.4/py3/ios/ui.html#about-actions-and-delegates
Hi, any more infos? Can i use it globally? BR kami