IronPython and Nodebox in C#

Posted by proxylittle on Stack Overflow See other posts from Stack Overflow or by proxylittle
Published on 2011-01-02T16:10:24Z Indexed on 2011/01/02 23:54 UTC
Read the original article Hit count: 503

Filed under:
|
|
|

My plan:

I'm trying to setup my C# project to communicate with Nodebox to call a certain function which populates a graph and draws it in a new window.

Current situation: [fixed... see Update2]

I have already included all python-modules needed, but im still getting a

Library 'GL' not found

it seems that the pyglet module needs a reference to GL/gl.h, but can't find it due to IronPython behaviour.

Requirement:

The project needs to stay as small as possible without installing new packages. Thats why i have copied all my modules into the project-folder and would like to keep it that or a similar way.

My question:

Is there a certain workaround for my problem or a fix for the library-folder missmatch. Have read some articles about Tao-Opengl and OpenTK but can't find a good solution.

Update1:

Updated my sourcecode with a small pyglet window-rendering example. Problem is in pyglet and referenced c-Objects. How do i include them in my c# project to be called? No idea so far... experimenting alittle now. Keeping you updated.

SampleCode C#:

ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null);
ScriptRuntime runtime = new ScriptRuntime(setup);
ScriptEngine engine = Python.GetEngine(runtime);

ScriptSource source = engine.CreateScriptSourceFromFile("test.py");
ScriptScope scope = engine.CreateScope();
source.Execute(scope);

SampleCode Python (test.py):

from nodebox.graphics import *
from nodebox.graphics.physics import Vector, Boid, Flock, Obstacle

flock = Flock(50, x=-50, y=-50, width=700, height=400)
flock.sight(80)

def draw(canvas):
    canvas.clear()
    flock.update(separation=0.4, cohesion=0.6, alignment=0.1, teleport=True)
    for boid in flock:
        push()
        translate(boid.x, boid.y)
        scale(0.5 + boid.depth)
        rotate(boid.heading)
        arrow(0, 0, 15)
        pop()

canvas.size = 600, 300

def main(canvas):
    canvas.run(draw)

Update2:

Line 139 [pyglet/lib.py] sys.platform is not win32... there was the error. Fixed it by just using the line:

from pyglet.gl.lib_wgl import link_GL, link_GLU, link_WGL

Now the following Error:

'module' object has no attribute '_getframe'

Kind of a pain to fix it. Updating with results...

Update3:

Fixed by adding following line right after first line in C#-Code:

setup.Options["Frames"] = true;

Current Problem:

No module named unicodedata, but in Python26/DLLs is only a *.pyd file`. So.. how do i implement it now?!

© Stack Overflow or respective owner

Related posts about c#

Related posts about python