Developing in NOX:


Building a Python only component

Pure python components are much simpler to construct than C++ components. As an example, see src/nox/apps/examples/ A Python component must have the following construction:

   from nox.lib.core import *
   class foo(Component):
       def __init__(self, ctxt):
           Component.__init__(self, ctxt)
       def install(self):
           # register for event here
       def getInterface(self):
           return str(foo)
   def getFactory():
       class Factory:
           def instance(self, ctxt):
               return foo(ctxt)
       return Factory()

You may optionally add a configure method which is called in the same order as for C++ (before install on startup). The following steps should be all that is needed to build a bare-bones python component for NOX.

Add your .py file to src/nox/coreapps/examples/ Copy code from src/nox/coreapps/examples/ (you need to mirror everything except for the code under the install method) Add your Python file(s) to NOX_RUNTIMEFILES in src/nox/apps/examples/ Update src/nox/apps/examples/meta.json to include your new app. Make sure that “python” is a dependency (copying is the best approach). After you're done, recompile following the same 3 steps (the build/ directory is already there now)


  • The core python API is in nox/lib/ and nox/lib/
  • To get a handle to another component, use the Component.resolve(..) method on the class or interface to which you want a handle. For example:
   from import pyswitch
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页