Autoreply. Hmm, Ok, I can put a module in ApplicationSupport. So, just need a startup file.
Best
Ok, my idea was to put a module (e.g. "misc") inside Application Support/NodeBox. In the misc module I have the definitions of some functions using NodeBox' commands, e.g line.
However, if I do in a new script:
from misc import *an error is raised:
Traceback (most recent call last):
File "nodebox/gui/mac/__init__.pyo", line 358, in _execScript
File "", line 5, in
File "/Users/andreavalle/Library/Application Support/NodeBox/misc.py", line 21, in arLine
NameError: global name 'line' is not defined
so, the misc module does not know NodeBox
I guess I should add something like
from nodebox import *inside misc.
?
Many thanks
-a-
Hi,
I think the ximport command is what you need. The imported module gets access to a "_ctx" variable, that has all the NodeBox commands, such as _ctx.line(10, 20, 30, 40) .
For more info, check out the docs:
http://nodebox.net/code/index.php/Libraries
Kind regards,
Frederik
Hi Frederik,
thanks. I've been able to create a package by putting a folder "andrea" with an __init__.py file into app support containing e.g.:
def myline(a,b,c,d): return _ctx.line(a,b,c,d)so in my script I can have
a = ximport("andrea") strokewidth(10) stroke(color(0,0,0)) a.myline(40, 50, 60, 154)Still, I don't know what to write in other files of the package to make them use nodebox .
E.g. I have another file in the package "andrea"
with
def circle(x, y, radius, other = None): if other == None: other = radius return oval(x-radius*0.5, y-other*0.5, radius, other)If my script now I write
a = ximport("andrea") strokewidth(10) stroke(color(0,0,0)) a.myline(40, 50, 60, 154)a.circle(10,10, 40) I 'm obtaining:
Traceback (most recent call last):
File "nodebox/gui/mac/__init__.pyo", line 358, in _execScript
File "/uni/pollenzo/slides/testscript.py", line 6, in
AttributeError: 'module' object has no attribute 'circle'
Hmm
Thanks a lot
-a-
startup?
Posted by andrea on Apr 12, 2008Hi,
As with other definitions (such as for circle and square) I need arrow line many times, so I have to write the def in each file.I'm using NB to create slides. It's a bit eccentric but works much better than powerpoint/impress (which I hate) and than TeX approaches I used (too boring).
I created a sort of css file, which I import with exec.
I needed arrows, so I defined this which seems to work fine:
Is there a way/plan to have NB read a startup file with my defs?
What's the way to extend it by adding my own func/classes?
Many thanks
-a-