Giter Club home page Giter Club logo

Comments (5)

cjrh avatar cjrh commented on June 22, 2024

The original code causing the problem is here (mayavi/tools/modules.py:72):

def _line_width_changed(self):
    try:
        self._target.actor.property.line_width = self.line_width
    except AttributeError:
        try:
            self._target.property.line_width = self.line_width
        except AttributeError:
            pass

It turns out that when "line_width" is not an attribute of whatever object is actor.property or _target.property, a TraitError is thrown (for at least some items) and not an AttributeError, which is what would be handled by the exception handlers above. TraitError is defined in another package called traits, which is in a separate folder to mayavi. I have modified my local copy of modules.py:72 to look like this:

def _line_width_changed(self):
    if hasattr(self._target, 'actor') and \
       hasattr(self._target.actor, 'property') and \
       hasattr(self._target.actor.property, 'line_width'):
        self._target.actor.property.line_width = self.line_width
    elif hasattr(self._target, 'property') and \
       hasattr(self._target.property, 'line_width'):
        self._target.property.line_width = self.line_width

Basically, I am explicitly testing for the presence of the desired attributes. I have nowhere near enough knowledge about the mayavi codebase to know whether this is the right way to approach this problem or not. Adding an import (from traits.api import TraitError) and adding TraitError to the exception handlers in the original code feels icky to me.

from mayavi.

jgosmann avatar jgosmann commented on June 22, 2024

I'm having the same problem.

from mayavi.

alkalinin avatar alkalinin commented on June 22, 2024

A also have this problem, my environment Windows 7, python(x,y) distribution.

Thank you for your patch, it solve this problem in my environment!

from mayavi.

johnyf avatar johnyf commented on June 22, 2024

Same here on Mac OS X 10.8.4, with MacPorts Python 2.7.6, py27-mayavi @4.2.0_1. The proposed patch fixes the error, in my case triggered when running the pick_on_surface.py example.

from mayavi.

prabhuramachandran avatar prabhuramachandran commented on June 22, 2024

Fixed with #96.

from mayavi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.