• simple

    Thanks for all the help, I am glad there are people like you out there! I will see if your code works, but I assume there is a problem with Pythonista on iOS on certain devices. I've send a friend of mine the file and he was able to run it on his iPad, but on his iPhone (iPhone 6 on iOS 9.3.3) it crashed the application.

    I will backup all Pythonista modules and scripts installed, remove and reinstall the application fresh, to see if something else causes the crash.

    posted in Pythonista read more
  • simple

    I've now tested a few code snippets and there still seems to be a problem.

    The same script launched several times sometimes activates the camera and sometimes not. If I got back to the button activated camera it doesn't work no matter what I do.

    posted in Pythonista read more
  • simple

    Ok, I got it working.

    I've reduced the code to a minimum and checked what happens. With this, Pythonista freezes, I have to remove it from the iOS switch and restart the application.

    import ui
    import photos
    
    class Extracter(ui.View):
        def __init__(self):
            print('Executed')
            photos.capture_image()
            
    if __name__=='__main__':
        view = Extracter()
    

    After that I tried to put the photo.capture_image() out of the class, that worked before and still does but is not what I want.

    import ui
    import photos
    
    photos.capture_image()
    
    class Extracter(ui.View):
        def __init__(self):
            print('Executed')
            
    if __name__=='__main__':
        view = Extracter()
    

    Now after your post @cvp I've double checked that Pythonista has camera permissions. I've disabled it and run the first script, and the camera launched (!) but without a picture. I went back to settings and enabled it again, and now it works.

    I've tested that on the second iPhone. If you run the script it freezes as before, disable and enable camera permissions again, and it works.

    posted in Pythonista read more
  • simple

    If you first see the UI button the code works as it should.

    On my iPhones if I launch the script the camera opens immediately and I don't see the ui.view sheet.

    (Edit: I've been mistaken, I do see the ui.view sheet with the button.. I thought that the black ui.view was the camera and not the ui.view. Still, if I press the button the application crashes.)

    posted in Pythonista read more
  • simple

    But that's not how the code should work, or did I understand that wrong (explained it wrong)?

    It should first show the ui.view sheet with a button called 'Take Photo'. Then you press that button and the camera launches and then you take the photo.

    posted in Pythonista read more
  • simple

    I've Pythonista 3 installed with default interpreter 3.5 on latest iOS 9.3.3

    @cvp When you launch the script, do you have to press the button to activate the camera? If I launch it, the camera activates first (I don't see the sheet with the button).

    posted in Pythonista read more
  • simple

    In the initial code sample I don't save the received image, and the application stops responding, so that shouldn't be the problem.

    The save_image(image) should still work since it is available for backwards compatibility, but was replaced for create_image_asset().

    But first I have to be able to take the image :)

    (Edit: I've tried the same script on an iPhone 6 and it crashes the application too. I've also checked that Pythonista has access to the camera.)

    posted in Pythonista read more
  • simple

    On iPhone 6 Plus Pythonista stops responing, even with the subview added, which I intentionally had left out (I thought it would make the code here cleaner, but you are right to add it since it is needed). I've to remove it from the switch to reopen the application.

    Sometimes it stops after the press, sometimes the 'camera sheet' slides up but is all black and in the upper right corner is the 'Take Photo' button. After that it stops responing too.

    posted in Pythonista read more
  • simple

    Hi, I want to create a button that launches the camera (...and saves the photo in the next step). Somehow whenever I press the button with photos.capture_image() in the script below, Pythonsista freezes. I thought that I could get around this with masking it with @ui.in_background but that doesn't work. Some idea how to trigger the camera from the button? (Note: If I write the photos.capture_image() outside of the ui.View class it launches the camera)

    import ui
    import console
    import clipboard
    import photos
    
    class Extracter(ui.View):
      def __init__(self):
    
      # Some UI Elements 
      (...)
    
      # Take Photo Button
      self.take_photo = ui.Button(flex = 'LR', title = 'Take Photo')
      self.take_photo.action = self.take_photo_action
      # Some Button Styles
      (...)
    
      # Take Photo Action
      @ui.in_background
      def take_photo_action(self, sender):
        image = photos.capture_image()
    
    if __name__=='__main__':
      view = Extracter()
    

    posted in Pythonista read more
  • simple

    Thanks, didn't know that. It now works!

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!