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?
-
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?
-
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
andpyui
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
andpyui
file. Its functionality is very limited compared to the other options, but it requires no additional tools for the end user. -
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.
-
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())
-
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.
-
@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. -
-
@Webmaster4o
How would I change the file to a .json ending. adding it directly to the filename only makes it file_name.json.pyuiThis method sounds like a good one where you can simple change the json file back to pyui when it is downloaded.
-
@TutorialDoctor This is only possible in the beta.
-
-
@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.
-
You can use os.rename() to rename a file from pyui to json...
-
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.
-
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.