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.


    Displaying an image

    Pythonista
    5
    9
    6777
    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.
    • freeradical321
      freeradical321 last edited by

      Hey guys,

      I'm completely new to pythonista, as well as python, and while we're at it, I'm completely new to programing in general! As such, I have what is probably a very simple question.

      How do I display an image in pythonista on the ipad? I'm just trying to get my program to display one of the emojis included within the app, but I can't get it to work. Is there a package/module I need to load? What command should I be using? Help?

      Thanks in advance

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

        There are a variety of ways to display images in different contexts. I suggest you look in the examples. Many use images in different ways. Besides the image demo examples several of the games are based on displaying and modifying images. Also try searching the doc for "image".

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

          BTW when you say "I couldn't get it to work" and ask for help you should post an example of what you tried. Otherwise the question is too vague to easily answer.

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

            import console, os
            
            # 'Smiling_1' can easily replaced by another image via  the + button
            path = os.path.expanduser('~') + '/Pythonista.app/Textures/' + 'Smiling_1' + '.png'
            console.show_image(path)
            
            1 Reply Last reply Reply Quote 0
            • omz
              omz last edited by

              A bit simpler:

              import Image
              img = Image.open('Smiling_1')
              img.show()
              
              1 Reply Last reply Reply Quote 0
              • ccc
                ccc last edited by

                You can also use path = os.path.expanduser('~/Pythonista.app/Textures/Smiling_1.png') to get the same path.

                In Pythonista v1.6, no image is shown :-( not even with the new syntax: console.show_image('emj:Smiling_1').

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

                  @ccc console.show_image only works with file paths, not built-in image names. I actually doubt that brumm's code would work even in Pythonista 1.5 (can't check right now) because the filesystem location of app bundles has changed in iOS 8 (the app bundle and the user documents are no longer in the same hierarchy).

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

                    @omz The code works fine with Pythonista 1.5 and iOS 8.3. Of course I haven't reinstalled Pythonista a long time (and not under iOS 8), so could it be that the old structure is valid? I hope I can update soon... ;)

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

                      I gotta say that I have learned to never second guess the code of Brumm... If he writes it then I believe. ;-)

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