0

我有一个 PySide/VTK 应用程序,使用 QVTKRenderWindowInteractor 连接。PySide 1.0.9 在带有 QT4.8/VTK 5.8 的基于 Unix 的系统上运行良好。(所有 Python 2.7.3)

然后我在 Microsoft Windows 系统 (XP 32) 上移植,使用 PySide win32 分发版 (1.1.x) Qt4 和 VTK 5.10,我在 QVTKRenderWindowInteractor 中出现类型错误,同时检索 self.winId() 预计可转换为诠释:

TypeError: int() argument must be a string or a number, not 'PyCObject'

PySide API 实际上说 PySide.QtGui.QWidget.winId() 返回一个长...

我正在 MS-Windows 和 Unix 上开始更多测试,但也许你们中的一些人可以给我一些建议?我必须寻找什么以及在哪里寻找?

是否与Qt 的 PySide 接口生成器生成的32 位系统上的这种long的错误转换有关?

见第 152 行 http://sourceforge.net/p/pycgns/code/ci/17b696c3b0ad2b387b7e0ddc5d9b195cbc6abf70/tree/NAVigater/CGNS/NAV/Q7VTKRenderWindowInteractor.py

4

1 回答 1

0

将此行替换为:

WId = self.winId()

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)

self._RenderWindow.SetWindowInfo(str(int(WId)))
于 2013-07-26T00:54:34.763 回答