Menu

pypredef and submodules

Moguri
2011-01-08
2013-03-15
  • Moguri

    Moguri - 2011-01-08

    I have a module (bge) that only contains submodules (eg, render and logic). What is the proper way to create pypredef files for these? Currently I have a bge.pypredef, bge.render.pypredef and bge.logic.pypredef. bge.pypredef only has imports in it (import render; import logic). Without the imports using "bge." does nothing. However, the problem is this works (with the imports in bge.pypredef):

    from bge import logic
    logic.foo # foo auto-completes
    

    but this doesn't:

    import bge
    bge.logic.foo # logic will auto-complete, but not foo
    

    I'd like to be able to do the latter. Any thoughts?

    Thanks,
    Moguri

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-01-08

    It works as if it was python code, so, as you have different packages, you have to import the package you're using - i.e.: you have to add an import at bge to import the bge.logic package (as you'd need in regular python code).

    E.g.:
    bge.pypredef containing:
    from bge import logic

    bge.logic.pypredef containing:
    class foo:
        pass

    Cheers,

    Fabio