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.


    Possible to share pyui files?

    Pythonista
    8
    14
    10257
    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.
    • dgm
      dgm last edited by

      Hello everyone,

      I downloaded pythonista a couple weeks ago and created a forum account a few days ago, but this is my first post. I wanted to first mention that I also downloaded editorial (although I'm not sure if I will use it much), in support of pythonista. I would really like to thank omz for the time and support of pythonista.

      I know its just a few days shy (hopefully) of 2.0, but here is my first question..

      How would I go about sharing code that uses pyui files? I created a basic image editing app that I would like to share, and if it was pure python, copy and paste would be easy. I do not know how someone would get my pyui file(s) into their device (without publishing to app store). Is it possible?

      1 Reply Last reply Reply Quote 1
      • dgelessus
        dgelessus last edited by dgelessus

        There are a few ways. pyui files are actually just JSON files, so they can technically be shared just like any other text file.

        First of all you can use Pythonista's built-in share button to upload an entire folder's contents to https://gist.github.com/, which will include any py and pyui files. Downloading those files again is not as straightforward, Pythonista has no built-in functionality for that. There is a utility named gistcheck which can be used to download gists.

        You can also keep the pyui files in a normal Git(Hub) repo, since they are just text files. The best ways to use Git repos in Pythonista at the moment are StaSh and @JonB's gitview/gitui. (Gists are also Git repos, so you can use those tools to download and manage gists too.)

        Then there's also a small utility called PackUI that I wrote a while back, which creates a "self-extracting" Python script containing a py and pyui file. Its functionality is very limited compared to the other options, but it requires no additional tools for the end user.

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

          For an even easier solution, just rename the file with a .json ending (Not sure if you can do this in 1.5). Alternatively, use

          print open('myfile.pyui').read()
          

          and copy/paste that.

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

            If you want to copy it directly, you can use the clipboard module:

            import clipboard
            
            with open("thing.pyui") as f:
                clipboard.set(f.read())
            
            1 Reply Last reply Reply Quote 1
            • dgm
              dgm last edited by

              Thank you! The PackUI script is perfect! I will mess around with reading, printing, and copying later.

              Is it ok for me to post the results here if anyone wants to check it out? They seem kind of long.

              1 Reply Last reply Reply Quote 1
              • Cethric
                Cethric last edited by

                @dgm while posting the code is allowed it is good practice to put it some where more appropriate (GitHub, GitLab, Mecurial, PasteBin, BitBucket, etc) and then post the link to it here, as this also makes it easier for us to play around with your programs. We can simply download it instead of trying to copy and paste the HTML version of the code.
                It also means we can provide more constructive feedback.

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

                  @Cethric thanks for the clarification.

                  The uipacked files can be found Here. This is my first time using github, so I hope I did it right.

                  Edit: I took down the packed files as per @Cethric 's advice. The original files can now be found in the same place.

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

                    @Webmaster4o
                    How would I change the file to a .json ending. adding it directly to the filename only makes it file_name.json.pyui

                    This method sounds like a good one where you can simple change the json file back to pyui when it is downloaded.

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

                      @TutorialDoctor This is only possible in the beta.

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

                        another script :)

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

                          @TutorialDoctor I should have said not sure if it will work in 1.5. That was a typo. It won't work unless you're on the beta.

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

                            You can use os.rename() to rename a file from pyui to json...

                            1 Reply Last reply Reply Quote 1
                            • dgelessus
                              dgelessus last edited by

                              Renaming files and folders using Python's library functions works normally on 1.5, as @JonB said. The file name box in the editor is however very persistent in keeping the current file extension. This has been changed in the beta, now changing a file's extension is much easier.

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

                                Last night I figured out a neat way to share pyui files. I created two actions, one that converts pyui files into json, and another to convert json into pyui. This way we can share the .json files and things are well.

                                The github link

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