""" A dialog with Mayavi ==================== Simple example demoing a dialog with Mayavi """ import numpy as np from traits.api import HasTraits, Instance from traitsui.api import View, Item, HGroup from mayavi.core.ui.api import SceneEditor, MlabSceneModel def curve(n_turns): "The function creating the x, y, z coordinates needed to plot" phi = np.linspace(0, 2*np.pi, 2000) return [np.cos(phi) * (1 + 0.5*np.cos(n_turns*phi)), np.sin(phi) * (1 + 0.5*np.cos(n_turns*phi)), 0.5*np.sin(n_turns*phi)] class Visualization(HasTraits): "The class that contains the dialog" scene = Instance(MlabSceneModel, ()) def __init__(self): HasTraits.__init__(self) x, y, z = curve(n_turns=2) # Populating our plot self.plot = self.scene.mlab.plot3d(x, y, z) # Describe the dialog view = View(Item('scene', height=300, show_label=False, editor=SceneEditor()), HGroup('n_turns'), resizable=True) # Fire up the dialog Visualization().configure_traits()