Photo Selector mod...
I get that the Photo module is proprietary to @omz, and thus not accessible, but does any one know how I might be able to get it to display the number of photos selected, <during> the selection process..
I am imagining some sort of wrapper that does not require me to keep sending a user back to select the correct number of photos, a very frustrating experience.
I have no idea even how to start.
@adrius42 I use this kind of code
all_assets = photos.get_assets() self.assets =  n_min = 4 while len(self.assets) < n_min: pick_assets = photos.pick_asset(assets=all_assets, title='pick at least '+str(n_min-len(self.assets))+' photos', multi=True) if not pick_assets: # cancel by user return for asset in pick_assets: self.assets.append(asset) all_assets.remove(asset)
Brilliant! Change the title! Thanks Adrius42
This forum is just brilliant, am looking forwards to contribute more, am watching out for questions in my reach.
@adrius42 Not only the title, the code also removes the already picked photos from the presented ones 😉
Sadly, not in my use case, not sure why!?
while len(self.assets) < self.photonum: pick_assets = photos.pick_asset(assets=favourites.assets, title='Pick at least '+str(self.photonum-len(self.assets))+' photos', multi=True) if not pick_assets: # cancel by user return for asset in pick_assets: self.assets.append(asset) favourites.assets.remove(asset) ```. I simply swapped all.assets with favourite assets in your example code. I honestly can’t see how it works/ I haven’t got round to focussing on this issue yet... but if you could give me a pointer....
favourites.assets returns a new instance every call... it is not a typical attribute.
assets = favourites.assets.copy()
@adrius42 other solution is to move, like in my solution,
all_assets = favorites.assets outside the while loop so you only get once this list
and you remove the picked ones from all_assets
all_assets is only a variable name, you could use favorites_assets of course
It took me a while I kept getting weird errors I couldn’t grok (what do you mean it doesn’t have a .remove!?)
Eventually I understood not all variables are mine to name and the importance of understanding that .assets.remove is two operations on the set
Python is more powerful than I have yet fully grasped, but with your help I am getting there...
I sense I need to go back and grok some more basics but testing the boundaries of my knowledge is also fun, it just means that my knowledge graph looks more like an octopus than an ever expanding circle!
<<I thought I had created the set of photos outside the while loop
I thought favourites.assets was my variable>>
I was clearly wrong!