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.
Pydia: A package installer for Pythonista
-
-
your installer is a bit broken (missing imports, site-packages is nit a valid far name)
also, PLEASE PLEASE do not import UIKit and import Foundation.
First, you did not include these in your installer.
Second, these are neither past nor future proof, as not everything steven aliased is available in older ios versions, or may be available in future versions. no try/except makes this very fragile code.If you really don't want to alias only the classes you need, at least use this, as it will work with every ios version that pythonista works on or will work on.
from objc_util import * c= ObjCClass.get_names(prefix='UI')+ObjCClass.get_names(prefix='NS') for cls in c: if not cls.startswith('_'): try: globals()[cls]=ObjCClass(cls) except ValueError: pass
-
it also seems as if the main script is not quite complete, at least as installed from the installer. Several imports don't work ( i think the direcotry structure was changed)..
I can't wait to try this, the ui built from almost pure objc should be pretty interesting
-
Here's a shorter method of loading all
UI...
classes into the global namespace, if you really want to do that (I find it a bit wasteful):from objc_util import ObjCClass globals().update({n: ObjCClass(n) for n in ObjCClass.get_names('UI')})
@JonB The
startswith('_')
check seems unnecessary, given that the class names are already filtered by prefix. Also, aValueError
shouldn't really happen becauseget_names
only returns names of classes that actually exist.