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.


    Form_dialog that takes pictures and save locally

    Pythonista
    3
    7
    3961
    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.
    • Grun6
      Grun6 last edited by

      Hello,

      I've been trying for days to do the following, and run into the same NoneType problem. Here is what I am after: in addition to entering text, numbers, checkmarks, and dates in a form dialog, I would like to also take a picture, and store it locally.

      The "picture" row in the form dialog would have two buttons, one to take a picture, and one to show a preview of it. The form dialog return dictionary would return the path to the picture as the value for that given photo row.

      Example:

      fields = [{'type':'text', 'title':'First Name', 'key':'fname', 'value':''}, {'type':'photo', 'title':'ID card', 'key':'ID_photo', 'value':''}]
      dialogs.form_dialog(fields = fields)
      

      And say the user enters "Bob" as first name, and uses the buttons to take a picture that gets stored locally at path pictures/some_unique_id.jpeg
      Then the form dialog would return:

      {'fname':'Bob', 'ID_photo':'pictures/some_unique_id.jpeg'}
      

      In my attempts, I have used the photos module, the capture_image() function to get the image, and the image.save(path) function to save it.

      Any help would be greatly appreciated,
      Merry Christmas to you all,
      G

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        why not post a gist of your furthest attempt?

        1 Reply Last reply Reply Quote 0
        • Grun6
          Grun6 last edited by

          You are right. I thought it would be long here but a gist is perfect:
          https://gist.github.com/368433/043e7e00955b7f880d422d3961a79215

          Also you can use this code for the demo:

          import PhotoDialogs
          
          fields = [{'type':'text', 'title':'First Name', 'key':'fname', 'value':''}, {'type':'photo', 'title':'ID card', 'key':'ID_photo', 'value':''}]
          PhotoDialogs.form_dialog(fields = fields)
          
          

          Notice what happens when you press Done after a picture is taken.

          1 Reply Last reply Reply Quote 0
          • Grun6
            Grun6 last edited by

            Notice:

            • the photo type is implemented at line 94
            • the take_photo call is implemented at line 344
            • the rest is pretty much the form_dialog module (I have implemented a segmented type but it has nothing to do with the rest)

            It all works well, but it seems that the capture_image() call changes the self.container_view item

            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @Grun6 last edited by cvp

              @Grun6 if you comment the line just after wait_modal

              	#c.container_view = None
              

              The problem does not occur anymore, that proves that the wait_modal does not wait...

              Before this comment, I've tried @ui.in_background in front of some def, but without success.

              1 Reply Last reply Reply Quote 0
              • Grun6
                Grun6 last edited by

                wow. @cvp. I don't know what to say...I've been trying to sort this out for literally three days...
                Thanks so much for looking at it,
                Merry Christmas,
                G

                cvp 1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @Grun6 last edited by

                  @Grun6 Thanks, it was my 🎁

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors