donnieh last edited by
How come the photos.pick_image() call doesn't work inside a function but works outside?
def pick_photo(sender): pic = photos.pick_image()
omz last edited by
It does work in a function, but not within a ui action. The reason for this is that ui actions block the main thread of the app by default, which would essentially cause it to hang if it would present a modal dialog or anything like that. The
pick_imagefunction detects this, and simply does nothing in this case.
You can fix this by "decorating" your action with
@ui.in_background, like this:
@ui.in_background def pick_photo(sender): pic = photos.pick_image()