haluhak149 / pythonxy

Automatically exported from code.google.com/p/pythonxy
0 stars 0 forks source link

Mayavi/TVTK Figure initialisation problem #724

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If relevant, please answer to the following questions:
1. What version of Python(x,y) have you installed?
  2.7.6.0, all packages, all plugins

3. Have you selected the option "Customize installation directories"?
  No

5. Where did you install Python(x,y) itself?
  default path

6. Have you installed Python(x,y):
   For "All users"

7. What is your operating system?
   Windows 7

8. Is the operating system 64 bit?
    Yes

9. When you installed Python(x,y), were you logged in as :
    an administrator of the machine

10. If you are using Windows Vista/7, have you installed Python(x,y):
    by right-clicking on the installer and selecting "Run as an
administrator"

11. Regarding installed software on your machine, how did you clean your
machine before installing Python(x,y)  (multiple answers are possible):
b. you uninstalled any previous Python distribution (including the
official .msi)

What steps will reproduce the problem?
1. import enthought.mayavi.mlab as ml
2. f1 = ml.figure(1,size=(1000,1000),bgcolor=(1,1,1),fgcolor=(0,0,0))
The problem occurs both for qt4 and wx.

What is the expected output? What do you see instead?
* one would expect to simply have a figure opened with specified colors
* instead, a particular error message [1] repeatedly clutters the screen and 
all the drawings are black/white instead of colored

[1]
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\tvtk\pyface\ui\qt4\scene.py", line 73, in paintEvent
    scene.light_manager = light_manager.LightManager(scene)
  File "C:\Python27\lib\site-packages\tvtk\pyface\light_manager.py", line 351, in __init__
    light = CameraLight(self.renwin)
  File "C:\Python27\lib\site-packages\tvtk\pyface\light_manager.py", line 172, in __init__
    self._color_changed(self.color)
  File "C:\Python27\lib\site-packages\tvtk\pyface\light_manager.py", line 232, in _color_changed
    self.source.color = val
traits.trait_errors.TraitError: Cannot set the undefined 'color' attribute of a 
'Light' object.

Original issue reported on code.google.com by h...@cs.tu-berlin.de on 14 Mar 2014 at 8:29

GoogleCodeExporter commented 9 years ago
Found this from google searching the same error.  I tried to resurrect some 
6-month to 1-year old code from a previous version of Mayavi and EPD and 
started getting these errors.  I assumed it had something to do with the latest 
version of Mayavi.

I also thought it might have something to do with switching from PyQt to 
PySide, but the error occurs regardless of which one is used.

Original comment by flutefre...@gmail.com on 25 Mar 2014 at 5:40

GoogleCodeExporter commented 9 years ago
Found a fix!

In C:\Python27\Lib\site-packages\tvtk\pyface\light_manager.py, CameraLight 
class, _color_changed method, change:

    self.source.color = val
    to
    self.color = val

This was line 232 for me.

You can see above this in the CameraLight class variables / Traits that color 
is defined as a vtk_color_trait on line 156 (thus accessible as self.color). 
self.source refers to an instance of tvtk.Light, which I assume is a wrapped 
VTK Light object. Looking at the VTK API, it looks like SetColor may be 
write-only since it is a backwards compatibility wrapper which actually sets 
DiffuseColor and SpecularColor... the source doesn't show a GetColor anywhere: 
http://www.vtk.org/doc/nightly/html/classvtkLight.html#ae01c48b21dcc9f89baf64cec
ff90fd92. Maybe Mayavi updated which version of VTK they wrap with TVTK and 
this property was deprecated?

There's a Mayavi Issue for this which I've commented on here: 
https://github.com/enthought/mayavi/issues/126

Original comment by flutefre...@gmail.com on 25 Mar 2014 at 7:01

GoogleCodeExporter commented 9 years ago
Thanks, this solved the problem for me!

Original comment by heisenbe...@googlemail.com on 25 Mar 2014 at 4:21

GoogleCodeExporter commented 9 years ago
Thanks, #2 solved the same problem for me! But i wander how could the source 
file (C:\Python27\Lib\site-packages\tvtk\pyface\light_manager.py) is wrong?

Original comment by hesin...@gmail.com on 23 Apr 2014 at 2:08

GoogleCodeExporter commented 9 years ago
For me that change allows the 3D diagram to be produced, but just as with the 
original poster, the 3D elements are all black (though there is some 
light-source effects applied).  My diagram also has lines (not cylinders), and 
THEY show up in color in the same diagram.

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\tvtk\pyface\ui\qt4\scene.py", line 73, in paintEvent
    scene.light_manager = light_manager.LightManager(scene)
  File "C:\Python27\lib\site-packages\tvtk\pyface\light_manager.py", line 351, in __init__
    light = CameraLight(self.renwin)
  File "C:\Python27\lib\site-packages\tvtk\pyface\light_manager.py", line 172, in __init__
    self._color_changed(self.color)
  File "C:\Python27\lib\site-packages\tvtk\pyface\light_manager.py", line 232, in _color_changed
    self.color = val
traits.trait_errors.TraitError: Cannot set the undefined 'color' attribute of a 
'Light' object.

Original comment by aaronbramson on 29 May 2014 at 7:01