[vtkusers] wxpython + vtkAxesActor + wxVTKRenderWindow

Richard A Rowe rar109 at york.ac.uk
Fri Apr 20 14:17:13 EDT 2007


Dear vtkusers,

I hope someone can help me with this problem... I'm using wxpython to create a GUI for two vtk windows. Firstly is this a good choice or would a different GUI choice or another language other than python be more straight forward?

I'd like to display xyz orientation widgets within the display windows. I have coded a simple example of how to display the vtkAxesActor within a vtkRenderWindow.

However, since I'm currently using wxpython, I've been using wxVTKRenderWindow(). I'm not sure how to set the interactor of this or even if you can? I read somewhere that you should not use both wxVTKRenderWindow() and wxVTKRenderWindowInteractor() together, plus my efforts have resulted in no progress by doing so... It is my understanding that to use the vtkAxesActor with the vtkOrientationMarkerWidget one should set the interactor of the vtkOrientationMarkerWidget to the window interactor.

Is this possible with wxVTKRenderWindow()? A simple program is below illustrating the problem. 

I will be very thankful if someone can help me out here.

Kind Regards,

Richard A Rowe. 

import wx
from math import *
import vtk
from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor

class MainWindow(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self,parent,wx.ID_ANY,title,size = (600,600),
        style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)

        panel = wx.Panel(self)

        widget = wxVTKRenderWindowInteractor(panel, -1)

        ren = vtk.vtkRenderer()

        renWin = widget.GetRenderWindow()
        renWin.AddRenderer(ren)

        sphere = vtk.vtkSphereSource()

        sphereMapper = vtk.vtkPolyDataMapper()
        sphereMapper.SetInputConnection(sphere.GetOutputPort())

        sphereActor = vtk.vtkActor()
        sphereActor.SetMapper(sphereMapper)

        # AxesActor
        axes = vtk.vtkAxesActor()
        axes.SetShaftTypeToCylinder()

        # Orientation marker to be used with vtkAxesActor.
        marker = vtk.vtkOrientationMarkerWidget()
        marker.SetOrientationMarker(axes)
        marker.SetViewport(0,0,0.2,0.2)

        marker.SetInteractor(widget)
        marker.EnabledOn()
        marker.InteractiveOff()
        
        ren.AddActor(sphereActor)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(widget, 1, wx.EXPAND | wx.ALL, 5)
        self.SetSizer(sizer)
        self.Layout()

        self.Show(True)


app = wx.PySimpleApp()
frame = MainWindow(None, -1, "wxPython with vtk")
app.MainLoop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070420/654e84de/attachment.htm>


More information about the vtkusers mailing list