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.


    Gives an error at the line that I marked.

    Pythonista
    line error
    4
    5
    4323
    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.
    • happy_variable
      happy_variable last edited by ccc

      # coding: utf-8
      import ui
      import appex
      import Image
          
       
      v = ui.load_view()
      img = appex.get_image()
      if img:
          v["image"].image = ui.Image(str(img)) #Error occurs here, it says IOError couldn't display image or something like that
      v.present('sheet')
      if not img:
          v.close()
      

      How do I correct it? Please help!

      uj_jonas 1 Reply Last reply Reply Quote 0
      • uj_jonas
        uj_jonas @happy_variable last edited by uj_jonas

        @happy_variable
        I don't know why you get that error, but try appex.get_attachments()[0] instead of appex.get_image()
        That did it for me :/

        Oh, and remove the str() around img on the line you get the error

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

          appex.get_image() had issues that are now fixed in the current beta... See https://forum.omz-software.com/topic/3498/error-when-trying-to-get-a-photo-attachment-in-a-mail and https://github.com/omz/Pythonista-Issues/issues/169

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

            I think the main problem here is that appex.get_image() returns a PIL.Image, but the ui.Image constructor expects an image name or file path...

            Something like this should work (it's possible that workarounds are needed for the App Store version of Pythonista 3 because of the aforementioned bug in appex):

            img_data = appex.get_image_data()
            if img_data:
                v['image'].image = ui.Image.from_data(img_data)
            # ...
            
            1 Reply Last reply Reply Quote 0
            • happy_variable
              happy_variable last edited by

              Thanks a lot! THAT WORKS!!! Without you I could have wasted time on trying to correct this error!

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