From 95e3899ffce17d56e3cfe613391e7a505543b945 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 21 Feb 2011 09:28:31 +0000 Subject: [PATCH] 0021192: [CEA 453] Python examples for GUI module --- src/SALOME_PY/SalomePy.cxx | 11 +++++++---- src/SALOME_SWIG/examplevtk1.py | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/SALOME_PY/SalomePy.cxx b/src/SALOME_PY/SalomePy.cxx index f2a599327..2ef470c09 100755 --- a/src/SALOME_PY/SalomePy.cxx +++ b/src/SALOME_PY/SalomePy.cxx @@ -107,10 +107,13 @@ static PyObject* GetPyClass( const char* theClassName ) static PyObject* aVTKModule = 0; PyObject* aPyClass = 0; if( !aVTKModule ) { - if ( VTK_MAJOR_VERSION > 3 ) - aVTKModule = PyImport_ImportModule( "vtk.libvtkRenderingPython" ); - else - aVTKModule = PyImport_ImportModule( "libVTKGraphicsPython" ); +#if VTK_XVERSION < 30000 + aVTKModule = PyImport_ImportModule( "libVTKGraphicsPython" ); +#elif VTK_XVERSION < 50700 + aVTKModule = PyImport_ImportModule( "vtk.libvtkRenderingPython" ); +#else + aVTKModule = PyImport_ImportModule( "vtkRenderingPython" ); +#endif if( PyErr_Occurred() ) { PyErr_Print(); } diff --git a/src/SALOME_SWIG/examplevtk1.py b/src/SALOME_SWIG/examplevtk1.py index 715bbe26a..82aed5d24 100755 --- a/src/SALOME_SWIG/examplevtk1.py +++ b/src/SALOME_SWIG/examplevtk1.py @@ -24,18 +24,25 @@ # File : examplevtk1.py # Module : SALOME # + +import os import libSalomePy -import vtk +from vtk import * + +try: + from libvtkRenderingPython import * +except: + from vtkRenderingPython import * # get the "vtkRenderer": an OpenGL rendering context -ren=libSalomePy.getRenderer() +ren = libSalomePy.getRenderer() # create an actor and give it cone geometry -cone = vtk.vtkConeSource() +cone = vtkConeSource() cone.SetResolution(8) -coneMapper = vtk.vtkPolyDataMapper() +coneMapper = vtkPolyDataMapper() coneMapper.SetInput(cone.GetOutput()) -coneActor = vtk.vtkActor() +coneActor = vtkActor() coneActor.SetMapper(coneMapper) # assign our actor to the renderer -- 2.39.2