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.


    Pydia: A package installer for Pythonista

    Pythonista
    install cydia
    3
    4
    4759
    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.
    • ProfSpaceCadet
      ProfSpaceCadet last edited by ProfSpaceCadet

      Pydia Installer.py: https://gist.github.com/bmw1821/d9883042b95a818e6429

      Source Code: https://gist.github.com/bmw1821/bc2ccf257d60804be010

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

        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
        
        1 Reply Last reply Reply Quote 1
        • JonB
          JonB last edited by

          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

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

            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, a ValueError shouldn't really happen because get_names only returns names of classes that actually exist.

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