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

grid flow bug

Posted by Al on Dec 04, 2008

Hello everyone,
I've recently been struggling with setting the flow of the grid library to horizontal with grid.flow_horizontal(). When calling draw() I'd then get the following error message.

File "/Users/al/Library/Application Support/NodeBox/grid/__init__.py", line 883, in _traverse
UnboundLocalError: local variable 'column' referenced before assignment

After much tinkering with the code I was writing to no avail, I finally found the courage to open up the grid library file and try and track down the problem there. Fortunately, it wasn't too difficult.

If you change line 883 of file "__init__.py" in the grid library to the following:

if isinstance(cell, (rows, columns)):
the problem will be solved.
The original code referred to the classes 'row' and 'column'. The classes are actually defined as 'rows' and 'columns'.

Kind regards,
Al


 
Posted by Al on Dec 05, 2008

Having looked through the source for the grid library again I discover that there are classes defined for both 'row' and 'rows' and also 'column' and 'columns'.
Therefore, why I was experiencing the error I mentioned in my previous post and why the change I made fixed it is a total mystery to me.
I'm puzzled.

Al



Posted by Tom De Smedt on Dec 05, 2008

The "rows" and "columns" classes are simply lists of, mm, rows and columns, wrapped with some navigational sugar. Nothing to worry about. All functionality is in the "row" and "column" classes.

The error occurs because the same function refers both to a class named "column" and a variable named "column", which is not allowed. It's a typical thing in recursive code that you run out of names to label stuff.

The bug is fixed in the latest release of the Grid library.