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.


    How do I transfer code, such as PC to IPad?

    Pythonista
    8
    11
    10416
    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.
    • boo
      boo last edited by

      I have a similar question. I built an app (iphone) for work. Coworkers loved it, so they bought pythonista, SIMPLY TO USE MY APP and now I can't figure out how to share the GUI with them.

      HEEEEEEEEELLLLLLLLLPPPPPPPP

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

        Use "File Transfer" app to transfer file between devices.
        To send a script to "File Transfer" from Pythonista use "Share" and "Open In" to import in File transfer.
        To open a script from "File Transfer" to Pythonista, use "To other app" in "File Transfer" and on the bottom list select "Run Pythonista Script"

        Then use this script in Pythonista to save any file from the previous "run Pythonista Script"

        # coding: utf-8
        
        import appex
        import clipboard
        import console
        import shutil
        import os
        
        def getuniquename(filename, ext):
        	root, extension = os.path.splitext(filename)
        	if ext!='':
        		extension = ext
        	filename = root + extension
        	filenum = 1
        	while os.path.isfile(filename):
        		filename = '{} {}{}'.format(root, filenum, extension)
        		filenum += 1
        	return filename
        
        def main():
        	console.clear()
        	dest_path_short = '~/Documents/inbox'
        	dest_path = os.path.expanduser(dest_path_short)
        	if not os.path.isdir(dest_path):
        		print('Create ' + dest_path_short)
        		os.mkdir(dest_path)	
        	if not appex.is_running_extension():
        		print('Using clipboard content...')
        		text = clipboard.get()
        		assert text, 'No text on the clipboard!'
        		resp = console.alert('Alert!', 'Choose File Extension', '.py', '.pyui', hide_cancel_button=False)
        		if resp==1:
        			ext = '.py'
        		elif resp==2:
        			ext = '.pyui'
        		filename=os.path.join(dest_path,'clipboard')
        		filename=getuniquename(filename,ext)
        		while os.path.isfile(filename):
        			filename = '{} {}{}'.format(root, filenum, extension)
        			filenum += 1
        		with open(filename,'w') as f:
        			f.write(text)
        		print('Done!')		
        	else:
        		file = appex.get_file_path()	
        		print('Input path: %s' % file)
        		filename=os.path.join(dest_path, os.path.basename(file))
        		filename=getuniquename(filename,'')
        		shutil.copy(file,filename)
        	print('Saved in %s' % dest_path_short)
        	if not os.path.exists(filename):
        		print(' > Error file %s not found !' % os.path.basename(filename))
        	else:
        		print(' > as %s' % os.path.basename(filename))
        
        if __name__ == '__main__':
        	main()
        
        
        FarmerPaco 1 Reply Last reply Reply Quote 1
        • boo
          boo last edited by

          Thanks very much. Will let you know how it goes.

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

            why not add like qr code read function,like qpython.

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

              Worked on an ipad but not my friends iphone. This is maddeningly frustrating. This simple task should be much much easier.

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

                It is mainly due to Apple's restrictions such a utility is not built-in. I use the following simple steps to do the transfer.

                1. Save to gist

                  From the file navigation panel (script library - left side of editor panel), you can select multiple files (including .pyui files) and tap the share sheet icon at the bottom to save it to gist. You can save it as anonymous if you do not have gist account. The url will be available in clipboard and you can either store the url in a file using 'paste' or you can use the following script (stored as editor action) to mail the url to your friends.

                import dialogs, clipboard
                dialogs.share_text(clipboard.get())  
                
                1. Get from gist

                  Open the gist url in safari and run the share script savefile (utility from JonB). It will get all the files in gist and store them in the predefined directory.

                  You can get the share script by running the folowing script.

                import requests as r
                with open('savefile.py', 'w', encoding='utf-8') as f:
                    f.write(r.get('https://gist.githubusercontent.com/jsbain/fcb3f42932dde9b0ff6c122893d1b230/raw/ab19fcd73598b829413da4c487bf5896b7cddeb0/savefile.py').text)
                
                1 Reply Last reply Reply Quote 3
                • FarmerPaco
                  FarmerPaco @pat31700 last edited by

                  @pat31700 your script works great! Once added as an extension you can pull from any app actually. I use iFiles as my go between apps since it stores to cloud or any cloud service, and once in the cloud it can be had anywhere.
                  I work with young students and we use cloud storage as a centralized classroom to share and learn from each other so this solution works nicely for them to import each other's work.
                  So thank you.

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

                    I used the requests method too with github and it works very well... you solved my problem, thanks.

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

                      easiest method is to change file extension. e.g. change filename.py to filename.txt. ]
                      rename it back after receiving.

                      currently I found iOS cannot send some file types to Pythonista , e.g. *.py *.pem *.cer,
                      but I can send them after rename change file extension.

                      rename is easy. easy than that much code

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

                        Another simple, albeit crude, method is to use e-mail. I e-mail my first large python program to my own e-mail address, and then read the e-mail using the e-mail App on my iPhone.

                        Then I started to "Reply" to the e-mail in my e-mail App, which opens the original message in a new window. I deleted the text that was added at the top of the new message, and then did "Select all" and "Copy".

                        After doing that, I went to the Pythonista App and used "Paste" to paste the program text into the Pythonista edit window.

                        Then, finally, I went back to the e-mail App and cancelled the reply message.

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