<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
pre
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{font-family:Arial;
color:windowtext;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=EN-GB link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Hi,</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I read your Mayavi question from about a year ago, because I
have exactly the same problem. I believe it has to do with windows, because I have
seen it work under Linux. Did anyone reply to your query and if so, do you know
why the screen goes red?</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>I attached your email so that you know what I am talking
about.</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Thanks</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'>Alexej</span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<pre><font size=2 face="Courier New"><span style='font-size:10.0pt'>Hello NG,</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> I'm trying to follow the mayavi documentation in order to run</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>mayavi from python. In "Chapter 4. Using MayaVi from Python", there is</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>a simple example like this:</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'># generate the data.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>from Numeric import *</span></font></pre><pre><font
size=2 face="Courier New"><span lang=FR style='font-size:10.0pt'>import scipy</span></font></pre><pre><font
size=2 face="Courier New"><span lang=FR style='font-size:10.0pt'>x = (arange(50.0)-25)/2.0</span></font></pre><pre><font
size=2 face="Courier New"><span lang=FR style='font-size:10.0pt'>y = (arange(50.0)-25)/2.0</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>r = sqrt(x[:,NewAxis]**2+y**2)</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>z = 5.0*scipy.special.j0(r) # Bessel function of order 0</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'># now dump the data to a VTK file.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>import pyvtk</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'># Flatten the 2D array data as per VTK's requirements.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>z1 = reshape(transpose(z), (-1,))</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>point_data = pyvtk.PointData(pyvtk.Scalars(z1))</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>grid = pyvtk.StructuredPoints((50,50, 1), (-12.5, -12.5, 0), (0.5,</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>0.5, 1))</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>data = pyvtk.VtkData(grid, point_data)</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>data.tofile('test.vtk')</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>import mayavi</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>v = mayavi.mayavi() # create a MayaVi window.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>d = v.open_vtk('test.vtk', config=0) # open the data file.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'># The config option turns on/off showing a GUI control for the</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>data/filter/module.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'># load the filters.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>f = v.load_filter('WarpScalar', config=0) </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>n = v.load_filter('PolyDataNormals', 0)</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>n.fil.SetFeatureAngle (45) # configure the normals.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'># Load the necessary modules.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>m = v.load_module('SurfaceMap', 0)</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>a = v.load_module('Axes', 0)</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>a.axes.SetCornerOffset(0.0) # configure the axes module.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>o = v.load_module('Outline', 0)</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>v.Render() # Re-render the scene.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Everything goes fine, but at the end I obtain the mayavi window</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>completely red (without the expected surface/image), and when I click</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>on this window I get different errors depending on which Python editor</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>I run:</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>1) Pythonwin: Error: Microsoft Visual C++ Runtime Error. Everything</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Crashes. After this, I get a vtkwindow coming up and showing me the</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>"always-present" error message from mayavi:</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>"Generic Warning: In </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>/debian/stage/vtk-4.2.4/Rendering/vtkTkRenderWidget.cxx, line 638</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>A TkRenderWidget is being destroyed before it associated</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>vtkRenderWindow</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>is destroyed. This is very bad and usually due to the order in which </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>objects are being destroyed. Always destroy the vtkRenderWindow before</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>destroying the user interface components"</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>I don't know why, but with mayavi this warning is EXTREMELY common...</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>2) IDLE for Python: All is frozen, nothing happen, I have to kill</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Python;</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>3) Python Command Line: No windows appears, nothing happen.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Moreover, I would like to be able to compile my Python application to</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>a standalone EXE file by using py2exe, but py2exe complains about some</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>missing modules (either from mayavi and for scipy), and the created</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>EXE does not start.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>I have installed Python using the Enthought Installer for Python (with</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>lots of site-packages inside), located at:</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'><a
href="http://www.enthought.com/python/">http://www.enthought.com/python/</a></span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>I'm running Win2000, without administrator privileges (if this can</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>make differences).</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Does anyone have an idea?</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Thanks for every suggestion.</span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'> </span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Andrea.</span></font></pre>
<p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt;
font-family:Arial'> </span></font></p>
<!--endarticle--></div>
</body>
</html>