[vtkusers] Question about conversion of winId in QVTKRenderWindowInteractor.__init__

Elvis Stansvik elvis.stansvik at orexplore.com
Wed Jun 15 08:44:07 EDT 2016

Hi all,

I have a question about this chunk of code in

        WId = self.winId()

        # Python2
        if type(WId).__name__ == 'PyCObject':
            from ctypes import pythonapi, c_void_p, py_object

            pythonapi.PyCObject_AsVoidPtr.restype  = c_void_p
            pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]

            WId = pythonapi.PyCObject_AsVoidPtr(WId)

        # Python3
        elif type(WId).__name__ == 'PyCapsule':
            from ctypes import pythonapi, c_void_p, py_object, c_char_p

            pythonapi.PyCapsule_GetName.restype = c_char_p
            pythonapi.PyCapsule_GetName.argtypes = [py_object]

            name = pythonapi.PyCapsule_GetName(WId)

            pythonapi.PyCapsule_GetPointer.restype  = c_void_p
            pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p]

            WId = pythonapi.PyCapsule_GetPointer(WId, name)


On which platforms will these two code blocks kick in? (i.e., when is
winId() a PyCObject or PyCapsule?). It seems on Linux/X11 they do not,
since winId() returns a sip.voidptr which can be used directly in the
SetWindowInfo call.

Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160615/132d25f9/attachment.html>

More information about the vtkusers mailing list