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.


    Button freezes Pythonista

    Pythonista
    4
    18
    8867
    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.
    • ccc
      ccc last edited by

      @tony, instead of pasting your code here, it would be best if you edited the program at https://github.com/tjferry14/Fun-Pythonista-Tools/blob/master/speech.py and the submitted a "pull request". That way we can all be looking at the same version.

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User last edited by

        @ccc I'll maybe let techteej to do that when he's happy with his version.

        @techteej Import sound (just temporarily while you're testing, the beep will confirm the script is waiting for the video file) and then give ids to the form and submit button of form and submit. Then use this in your microphone button...

                sender.superview['webview1'].evaluate_javascript('document.getElementById("file").click()')
                def loop():
        			if sender.superview['webview1'].evaluate_javascript('document.forms["form"]["file"].value') == '':
        				sound.play_effect('Beep')
        				ui.delay(loop,2)
        			else:
        				sender.superview['webview1'].evaluate_javascript('document.getElementById("submit").click()')
                 loop()
        
        1 Reply Last reply Reply Quote 0
        • techteej
          techteej last edited by

          @tony This still crashes Pythonista.

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            @techteej It works here on iPad mini (original). If it doesn't work for you (from a clean start of Pythonista) then it may be to do with the threading issue. It's only a guess why the ui.delay of an empty function for zero time helps, all we can say for sure is 'it does because it does' on one device anyway.

            When Pythonista gets into the threading issue... one run of a script is not necessarily the same as a second... so it's worth to try from a clean start of Pythonista, (if you haven't already). Otherwise I don't know what to say except it must be frustrating (been there!)

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

              I am struggling to understand this code. get_unused_filename() and do_POST() never get called.

              do_GET() only gets called once with self.path set to '/'.

              What is supposed to happen after the user clicks "Use Video"?

              1 Reply Last reply Reply Quote 0
              • ?
                A Former User last edited by

                @ccc That part is basically @omz's file transfer script. The flow goes...

                First GET to the server is for the HTML.

                The POST will happen when the video file is being submitted... maybe you haven't got to that point. In turn it will call 'get unused file name' to get a free one if the name of the uploaded file is in use.

                iOS will pop up a choice to take a new photo/video or choose an exiting one... any of the choices are ok, and whatever file results will be uploaded, when the user (or the JavaScript) clicks the submit button.

                If you're using the JavaScript the user will never see the web page or the buttons, just the iOS pop up, which is nice and clean.

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

                  So when you click "Use Video" does do_Post() get called?

                  1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User last edited by

                    @ccc Yes... when the user (or the JavaScript) clicks the submit button. If you're using the JavaScript the user will never see the web page or buttons, just the iOS popup, which is nice and clean.

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

                      When I check the code out of the repo and run it and tap the record button and select "video" and record a video and tap "Use Video" nothing happens. There is no video file stored in the local directory. The beep in the background continues every 2 seconds until Pythonista times out.

                      Are you using the current code in the repo? What is the name and full path of the video file that gets saved?

                      1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User last edited by

                        @ccc The repo is missing the step of adding ids to the form and submit button of form and submit respectively. The file is saved to the same directory as the script. For a video it's capturedvideo.MOV.

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

                          I just submitted a pull request with the two ids added.

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