IronPython and Nodebox in C #

My plan:

I am trying to set up my C # project to communicate with Nodebox to call a specific function that fills the chart and draws it in a new window.

Current situation: [fixed ... see Update2]

I already included all the necessary python modules, but im still getting

Library 'GL' not found

it seems that the pyglet module needs a reference to GL/gl.h , but cannot find it due to the behavior of IronPython.

Requirements:

The project should remain as small as possible without installing new packages. That is why I copied all my modules into the project folder and would like to save this or similarly.

My question is:

Is there any workaround for my problem or a fix for the missmatch library. Read a few articles about Tao-Opengl and OpenTK , but can't find a good solution.

Update1:

Updated source code with a small pyglet rendering example. The problem is with the piglet and references to c-objects. How to include them in my C # project to call? No idea yet ... experiment now. Keeping your update.

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 ... an error has occurred. Fixed 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' 

The kind of pain to fix it. Update with results ...

Update3:

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

 setup.Options["Frames"] = true; 

Current issue:

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

Update4:

Fixed by surfing: link text and adding unicodedata.py and '.pyd in C # Projectfolder.

Current issue:

'libGL.so not found' ... guys .. im almost giving up nodebox for c # .. to continue

Update5:

i refused: / workaround: C # reporting from nodebox over xml and file systems. Not optimal, but the matter is settled.

+4
source share
1 answer

-X: Frames allow you to use frames as a runtime (it slows down the code a bit to have access to Python frames all the time).

To enable frames while hosting, you just need to do:

 ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(new Dictionary<string, object>() { { "Frames", true } }); 

Instead of the null value that you are passing now. It is simply creating a new dictionary for the parameter dictionary with the contents of the "Frames" set to true. You can also set other options, and in general the -X: Name option is the same as for the command line.

0
source

Source: https://habr.com/ru/post/1333992/


All Articles