1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Colors and size

Posted by Edwin on Feb 27, 2008

I have trouble with the color library.

Last night my code worked and this morning I get a
NameError: name 'size' is not defined

I have this a lot. I use a MacBook and 1.9.4 with even the latest color library (1.9.4)

colors = ximport("colors")
 
clr = colors.rgb(.8, .8, .61)
scheme = colors.complementary(clr)
scheme.swarm(175, 175)
scheme.swatch(350, 100, w=25, h=25)
gives me;
Traceback (most recent call last):
  File "nodebox/gui/mac/__init__.pyo", line 358, in _execScript
  File "/Users/trumpetto/Documents/NodeBox/_musichor_colorsheet.py", line 1, in 
  File "nodebox/graphics/__init__.pyo", line 57, in ximport
  File "/Users/trumpetto/Documents/NodeBox/colors.py", line 39, in 
NameError: name 'size' is not defined


 
Posted by Edwin on Feb 27, 2008

And now it works again...
Hard to pinpoit this one.



Posted by Tom De Smedt on Feb 29, 2008

That's odd. Actually some other people on the forum mentioned another odd thing or two relating to Colors but so far I haven't been able to reproduce them on our machines. Does this error occur only with Colors or in other scripts as well? Is the full script that generates the error?



Posted by Edwin on Mar 02, 2008

Very odd. Yep, that's the full script.
Had the 'encounter' again today.
I took the full code, pasted it into a new document, ran it (unsaved) and all was fine.

After restarting nodebox I had the same problem and removed every line with code refering to the Colors lib.
That didn't help. I had to remove the line

colors = ximport("colors")
before all ran OK again.

After a restart I experimented further an even better now: After running the code succesfully in the new document it also runs fine in the original troubled document.
It's voodoo but a solution I can live with for now because I LOVE nodebox. Very nice job!



Posted by Tom De Smedt on Mar 21, 2008

You should try renaming your script. If I'm not mistaken, right now it's name is "colors.py". So when you import the colors library in this file it will first of all search in its own folder and find itself. Then it tries to import itself and weird things happen.

Hope that helps,
Tom