Hi, creating a wxVTKRenderWindowInteractor fails with NotImplementedError and SystemError: <slot wrapper '__init__' of 'sip.simplewrapper' objects> returned a result with an exception set .
This happens on a second computer running Ubuntu 24.04.1, its working fine on 22.04.1. This might also be due to some other issue, the only difference I can make out at the moment is the different ubuntu version.
Example code:
import wx
import vtk
from vtkmodules.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
class MyFrame(wx.Frame):
def __init__(self, parent):
super().__init__(parent, title="wxVTK Example", size=(800, 600))
panel = wx.Panel(self)
self.vtk_widget = wxVTKRenderWindowInteractor(panel, -1) # This fails
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.vtk_widget, 1, wx.EXPAND)
panel.SetSizer(sizer)
renderer = vtk.vtkRenderer()
self.vtk_widget.GetRenderWindow().AddRenderer(renderer)
interactor = self.vtk_widget.GetRenderWindow().GetInteractor()
sphere = vtk.vtkSphereSource()
sphere.SetRadius(1.0)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(sphere.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
self.vtk_widget.Enable(1)
self.vtk_widget.Initialize()
if __name__ == "__main__":
app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()
This fails with the following stack trace:
NotImplementedError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/developer/3d-medical-imaging/wx_test.py", line 41, in <module>
frame = MyFrame(None)
^^^^^^^^^^^^^
File "/home/user/developer/3d-medical-imaging/wx_test.py", line 12, in __init__
self.vtk_widget = wxVTKRenderWindowInteractor(panel, -1) # This fails
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/developer/3d-medical-imaging/venv/lib/python3.11/site-packages/vtkmodules/wx/wxVTKRenderWindowInteractor.py", line 167, in __init__
baseClass.__init__(self, parent, ID, pos=position, size=size,
SystemError: <slot wrapper '__init__' of 'sip.simplewrapper' objects> returned a result with an exception set
Specs on machine where it doesn’t work:
python 3.11.14
24.04.1-Ubuntu
vtk==9.5.2
wx==4.2.5
OpenGL version string: 4.6 (Compatibility Profile) Mesa 25.2.8-0ubuntu0.24.04.1
$XDG_SESSION_TYPE = x11 (originally on wayland but also didn't work)
Spec on machine where it does work:
python 3.11.13
22.04.1-Ubuntu
vtk==9.5.2
wx==4.2.3
OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.04.3-1ubuntu3.1-22.04.1
$XDG_SESSION_TYPE = wayland
Maybe I’m having driver issues? I don’t really know how to track down the not implemented thing.. I guess some parameter combination doesn’t work for some reason.
Thanks for your advice!