<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:10pt"><div><span><div style="font-size: 10pt;"><span>I have solved the problem at least for the left mousebutton. The rest is pretty straight forward. It is all about styles.</span></div><div style="background-color: transparent;"><span>Don't know why the standard doesn't work out of the box when embedded into a QVTKWidget when it does outside this widget. It also seems to work under C++ without style changes. At least this is what the provided example in the sources makes me believe.</span></div><div style="background-color: transparent;"><span>Why is this? Can anyone explain at least this to me? Or am I doing something wrong?</span></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"><span>Here is the solution if the left mousebutton was clicked not to come up with a weird
 crash:</span></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;"><span><font size="2"><div style="background-color: transparent;">interactorStyle = vtk.vtkInteractorStyleImage()</div><div style="background-color: transparent;">widget.GetRenderWindow().GetInteractor().SetInteractorStyle( interactorStyle )</div></font></span></div><div style="background-color: transparent;"><br></div><div style="background-color: transparent;">Cheers,</div><div style="background-color: transparent;">Willi</div><div><br></div></span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span
 style="font-weight:bold;">Von:</span></b> Willi Huber &lt;surfersparadise85-vtk@yahoo.com&gt;<br> <b><span style="font-weight: bold;">An:</span></b> "vtkusers@vtk.org" &lt;vtkusers@vtk.org&gt; <br> <b><span style="font-weight: bold;">Gesendet:</span></b> 17:56 Donnerstag, 17.Januar 2013<br> <b><span style="font-weight: bold;">Betreff:</span></b> Re: [vtkusers] Again python debugging<br> </font> </div> <br><div id="yiv1763278402"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: tahoma, 'new york', times, serif; font-size: 10pt;"><div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt;">Dear Users of the VTK world,</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color:
 transparent; font-style: normal;">I have tried a lot now and my conclusion is that all the problems I am facing have to do<span style="background-color:transparent;">&nbsp;with the combination of VTK and Qt. Whenever I let Qt go and I use a usual RenderWindow and do the setup as intended everything is just fine.</span></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><span style="background-color:transparent;"><br></span></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">I now switched to using the QVTKWidget and tried to rebuild the&nbsp;Examples\GUI\Qt\FourPaneViewer Example of the vtk-source-tree in Python (because of the vtkResliceImageViewer) with just one widget now . All the settings are the same. Also the Observer or rather the Callback is
 there. Still the same error. I am desperately searching for an answer how to make it work.&nbsp;</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">My current code:</div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><pre style="font-size: 10pt; font-family: 'Courier
 New';">====&nbsp;python&nbsp;code ====</pre></div><div style="background-color:transparent;"><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; reader = vtk.vtkMetaImageReader()</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; reader.SetFileName( file )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp;
 reader.Update()</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; widget = qvtk.QVTKWidget( self.widget )</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; layout = QtGui.QVBoxLayout()</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; layout.addWidget( widget )</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; self.slider = QtGui.QSlider( Qt.Horizontal, self.widget )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; layout.addWidget( self.slider )</font></div><div style="
background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; self.widget.setLayout( layout )</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer = vtk.vtkResliceImageViewer()</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; widget.SetRenderWindow( viewer.GetRenderWindow() )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetupInteractor( widget.GetRenderWindow().GetInteractor() )</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; vtk.vtkResliceCursorLineRepresentation.SafeDownCast(
 viewer.GetResliceCursorWidget().GetRepresentation() ).GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal( 2 )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetInputConnection( reader.GetOutputPort() )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetSlice( 50 )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetSliceOrientation( 2 )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetResliceModeToAxisAligned()</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; cbk = vtkResliceCursorCallback()</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div
 style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.GetResliceCursorWidget().AddObserver( 'vtkResliceCursorWidget::ResliceAxesChangedEvent', cbk )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.GetResliceCursorWidget().AddObserver( 'vtkResliceCursorWidget::WindowLevelEvent', cbk )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.GetResliceCursorWidget().AddObserver( 'vtkResliceCursorWidget::ResliceThicknessChangedEvent', cbk )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.GetResliceCursorWidget().AddObserver( 'vtkResliceCursorWidget::ResetCursorEvent', cbk )</font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; viewer.GetInteractorStyle().AddObserver( 'vtkCommand::WindowLevelEvent', cbk
 )</font></div><div style="background-color:transparent;"><font size="2"><br></font></div><div style="background-color:transparent;"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp; widget.show()</font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><font size="2"><br></font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><font size="2"><pre style="font-size: 10pt; font-family: 'Courier New';">====&nbsp;end&nbsp;code ====</pre></font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><font size="2"><br></font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif;
 font-style: normal;"><font size="2">Where vtkResliceCursorCallback is this:</font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><font size="2"><br></font></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><font size="2"><pre style="font-size: 10pt; font-family: 'Courier New';">====&nbsp;python&nbsp;code ====</pre></font></div><div style="background-color:transparent;"><font size="2"><div style="background-color:transparent;">class vtkResliceCursorCallback:</div><div style="background-color:transparent;">&nbsp; &nbsp;def __init__( self ):</div><div style="background-color:transparent;">&nbsp; &nbsp; &nbsp; &nbsp;self.CallDataType = 'string0'</div><div style="background-color:transparent;"><br></div><div style="
background-color:transparent;">&nbsp; &nbsp;# Execute method usually</div><div style="background-color:transparent;">&nbsp; &nbsp;def __call__( self, obj, event, message ):</div><div style="background-color:transparent;">&nbsp; &nbsp; &nbsp; &nbsp;print event</div><div style="background-color:transparent;"><br></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><span style="font-family: 'Courier New'; font-size: 10pt; background-color: transparent;">====&nbsp;end code ====</span><br></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: tahoma, 'new york', times, serif; font-style: normal;"><span style="font-family: 'Courier New'; font-size: 10pt; background-color: transparent;"><br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New';
 font-style: normal;"><span style="font-family: tahoma, 'new york', times, serif;">I used the ErrorObserver of David Gobbi as guide.</span><br></div></font></div></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Please can anyone help me? Please Please.<br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color:
 transparent; font-style: normal;"><br></div><div style="font-family: tahoma, 'new york', times, serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;">  <div style="font-family: tahoma, 'new york', times, serif; font-size: 10pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">Von:</span></b> Willi Huber &lt;surfersparadise85-vtk@yahoo.com&gt;<br> <b><span style="font-weight:bold;">An:</span></b> surfersparadise85-vtk@yahoo.com; vtkusers@vtk.org <br> <b><span style="font-weight:bold;">Gesendet:</span></b> 12:07 Mittwoch, 16.Januar 2013<br> <b><span style="font-weight:bold;">Betreff:</span></b> AW: [vtkusers] Again python debugging<br> </font> </div>
 <br><br>Anyone?<br><br><br><br>------------------------------<br>Willi Huber schrieb am Di., 15. Jan 2013 04:55 MEZ:<br><br>&gt;Hello all,<br>&gt;<br>&gt;I am trying to do some new stuff and I am again hitting the debugging barriers of vtk in python.<br>&gt;<br>&gt;My code:<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; file = "test.mhd"<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; reader = vtk.vtkMetaImageReader()<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; reader.SetFileName(file)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; reader.Update() &nbsp;#just for checking because I had an observer attached to reader<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; iren = QVTKRenderWindowInteractor(self.widget)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; ren = vtk.vtkRenderer()<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; iren.GetRenderWindow().AddRenderer(ren)<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp;&nbsp;<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer = vtk.vtkResliceImageViewer()<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetRenderWindow(iren.GetRenderWindow())<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetRenderer(ren)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetupInteractor(iren)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetInput(reader.GetOutput())<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetSlice(50)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetColorWindow(2000.0)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; viewer.SetColorLevel(1000.0)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; layout = QtGui.QVBoxLayout()<br>&gt;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; layout.addWidget(iren)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; self.slider = QtGui.QSlider(Qt.Horizontal, self.widget)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;
 layout.addWidget(self.slider)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; self.widget.setLayout(layout)<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; iren.Initialize()<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; iren.Start()<br>&gt;<br>&gt;I can see the image in the first place.<br>&gt;When I use the right mouse button everything is fine and I can zoom in and out but when using the left mouse button the app suddenly freezes and the debugging window of Win7 appears - not the VTK window. It is sth. with a malloc at least this is what the debugger told me or rather stepped in.<br>&gt;I tried using the Error Observer suggested by David and mined every object I've access to. I also used the vtk.vtkFileOutputWindow() without any success. No file was written.<br>&gt;(The slider isn't currently attached to any object so you can ignore it.) Am I doing sth. wrong with the initialization?<br>&gt;<br>&gt;Can
 someone help me with this?<br>&gt;<br>&gt;Cheers,<br>&gt;Willi<br><br><br> </div> </div> </blockquote></div>   </div></div></div><br>_______________________________________________<br>Powered by www.kitware.com<br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br><br><br> </div> </div> </blockquote></div>   </div></body></html>