omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    photos.pick_image() Help

    Pythonista
    2
    2
    1042
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • donnieh
      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()
      
      1 Reply Last reply Reply Quote 0
      • omz
        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_image function 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()
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors