Ok, here is the gist:
https://gist.github.com/amdescombes/30839ae0280a5077b8669757e5efa75d
Cheers
Andre
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.
Ok, here is the gist:
https://gist.github.com/amdescombes/30839ae0280a5077b8669757e5efa75d
Cheers
Andre
Hi again,
I changed Jon's NSLog function to make it a little bit more efficient:
from objc_util import c, ns, c_void_p, c_void_p
_nslog = c.NSLog
_nslog.argtypes = [c_void_p, c_void_p]
_nslog.restype = None
def NSLog(msg):
_nslog(ns('%@'), ns(str(msg)))
I think it would be nice if it could be added to the objc_util package directly, as it has been very useful to me.
Notice I cast the msg parameter into a string, that way you can pass anything you want to it and it will output that to the XCode console.
Cheers
Andre
Hello everyone,
Here is a reworked script that adds the comments at the top but preservers coding= comments.
It is not perfect, but it helped me succesfully submit an app to the Appstore, I hope it is of help to every one.
#import pythonista
# Change the ********** to point to the directory containing the Pythonista framework :
project_path = '**********/PythonistaAppTemplate'
pylib_path1 = '%s/PythonistaKit.framework/pylib' % project_path
pylib_path2 = '%s/PythonistaKit.framework/pylib_ext' % project_path
MAX_REPEATS = 10
import shutil
import os
import subprocess
def check_is_executable(file_path):
file_output = subprocess.check_output(['file', file_path])
if 'executable' in file_output:
return True, file_output
return False, file_output
def fix_executable(file_path, dry_run=False):
with open(file_path, 'r') as f:
source = f.readlines()
if 'coding:' in source[0].lower():
firstline = source[0]
start = 1
else:
firstline = ''
start = 0
if dry_run:
if firstline:
print(firstline)
else:
with open(file_path, 'w') as f:
f.write(firstline + '#import pythonista\n' * MAX_REPEATS + ''.join(source[start:]))
is_executable, out = check_is_executable(file_path)
return not is_executable
def fix_pylib(pylib_path, dry_run=False):
print ("fixing", pylib_path)
for path, dirs, files in os.walk(pylib_path):
print(path, dirs, files)
for filename in files:
full_path = full_path = os.path.join(path, filename)
is_executable, file_output = check_is_executable(full_path)
if is_executable:
extension = os.path.splitext(full_path)[1].lower()
if extension in ['.py', '.pym'] or filename == 'command_template':
if dry_run:
print '### Executable found: %s' % (filename,)
fixed = fix_executable(full_path, dry_run)
else:
print 'Fixing %s...' % (filename,)
fixed = False
counter = 0
while not fixed:
fixed = fix_executable(full_path)
counter += MAX_REPEATS
print 'Fixed with '+str(counter)+' dummy lines.'
else:
print '### Executable found, but does not seem to be Python code: %s' % (full_path,)
if __name__ == '__main__':
fix_pylib(pylib_path1, False)
fix_pylib(pylib_path2, False)
Cheers
Andre
Hello everybody,
I found what was not working with the creation of my TableView using the PythonistaAppTemplate
When you use the following syntax it doesn't work:
tbl = ui.TableView(frame=(0, 0, 400, 600))
You have to do it in two lines and then it works, like so:
tbl = ui.TableView()
tbl.frame = (0, 0, 400, 600)
I hope this can be useful, it took me a long time to find out what was wrong.
Cheers
Andre
Thanks @mikashkin, I didn't think to look for them there :)
Andre
Thanks @ccc! now I can get those into PyCharm :-)
Andre