[vtkusers] broken vtkTkRenderWindowInteractor.py in 5.2.0?

Alexander Pletzer pletzer at txcorp.com
Tue Sep 2 11:47:26 EDT 2008


Mathieu,

I'm using Python 2.5. The code breaks in

vtkLoadPythonTkWidgets.py

    for path in pathlist:
        try:
            # try block needed when one uses Gordon McMillan's Python
            # Installer.
            if len(path) > 0 and path[0] == '{' and path[-1] == '}': <<<<<<<<<<<< fails here
                path = path[1:-1]
            fullpath = os.path.join(path, filename)
        except AttributeError:
            pass
        if ' ' in fullpath:
            fullpath = '{'+fullpath+'}'
        if interp.eval('catch {load '+fullpath+' '+pkgname+'}') == '0':
            return



because path is sometimes an object (_tkinter.Tcl_Obj) while being most 
of the time a string. It seems that something has changed between Python 
2.4 and Python 2.5 regarding the way exceptions are handled. The code 
works if I remove the AttributeError: Line 57

        except AttributeError:

by

        except: # AttributeError:

--Alex

 Malaterre wrote:
> Alex,
>
> On Tue, Sep 2, 2008 at 4:04 AM, Alexander Pletzer <pletzer at txcorp.com> wrote:
>   
>> Hi,
>>
>> I have downloaded and built vtk a few weeks ago from cvs. I'm encountering
>> an error I never had before, which can also be reproduced by running
>> vtkTkRenderWindowInteractor.py in standalone, ie running the
>> vtkRenderWindowInteractorConeExample() example:
>>
>> [pletzer at localhost tmp]$ python
>> /usr/lib/python2.5/site-packages/VTK-5.2.0-py2.5.egg/vtk/tk/vtkTkRenderWindowInteractor.py
>> Traceback (most recent call last):
>>  File
>> "/usr/lib/python2.5/site-packages/VTK-5.2.0-py2.5.egg/vtk/tk/vtkTkRenderWindowInteractor.py",
>> line 394, in <module>
>>   vtkRenderWindowInteractorConeExample()
>>  File
>> "/usr/lib/python2.5/site-packages/VTK-5.2.0-py2.5.egg/vtk/tk/vtkTkRenderWindowInteractor.py",
>> line 364, in vtkRenderWindowInteractorConeExample
>>   pane = vtkTkRenderWindowInteractor(root, width=300, height=300)
>>  File
>> "/usr/lib/python2.5/site-packages/VTK-5.2.0-py2.5.egg/vtk/tk/vtkTkRenderWindowInteractor.py",
>> line 48, in __init__
>>   vtkLoadPythonTkWidgets(master.tk)
>>  File
>> "/usr/lib/python2.5/site-packages/VTK-5.2.0-py2.5.egg/vtk/tk/vtkLoadPythonTkWidgets.py",
>> line 54, in vtkLoadPythonTkWidgets
>>   if len(path) > 0 and path[0] == '{' and path[-1] == '}':
>> TypeError: object of type '_tkinter.Tcl_Obj' has no len()
>>
>>
>>     
>>>>> v = vtk.vtkVersion()
>>>>> print v.GetVTKVersion()
>>>>>           
>> 5.2.0
>>
>>
>> Any suggestion would be welcome. Thanks for your help.
>>     
>
> That has nothing to do with VTK AFAIK. Could you try something like:
>
>
> $ python
>   
>>>> s = "bla"
>>>> len(s)
>>>>         
>
> len is supposed to be a build in function of python. Or maybe you are
> using Python 3.0 and they seriously broke backward compatibility ;)
>
> 2cts
>   




More information about the vtkusers mailing list