Traitsui (Array into Sliders)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Traitsui (Array into Sliders)

Jan Kurzawski
Hi all,

I wrote simple traitsui code with one ojbect - red sphere. The thing I want to do is change the origin of the sphere not by putting the number into array in gui but by using a slider. The thing is how to change the array in gui into the slider.
Any help would be great!

import mayavi
from mayavi import mlab
from enthought.traits.api import HasTraits, Instance, Range, Bool, Str, Enum, Array
from enthought.mayavi.tools.mlab_scene_model import MlabSceneModel
from enthought.mayavi.core.ui.mayavi_scene import MayaviScene
from enthought.traits.ui.api import View, Item, Group,HSplit, VSplit, HGroup
from enthought.tvtk.pyface.scene_editor import SceneEditor
import numpy as np

class ActorViewer(HasTraits):

    # The scene model.
    scene = Instance(MlabSceneModel, ())
    view = View(HSplit(VSplit(Item(name='scene', 
                     editor=SceneEditor(scene_class=MayaviScene),
                     show_label=False,
                     resizable=False,
                     height=400,
               width=400)),Group(('visibility','center'))))


    visibility = Bool(True)
    center=Array(np.float64,(3,))

    def __init__(self, **traits):
        HasTraits.__init__(self, **traits)
        self.generate_data()
        
    
    def generate_data(self):


        sphere = self.scene.mlab.points3d(0, 0, 0, scale_mode='none',
                                scale_factor=2,
                                color=(1, 0, 0),
                                resolution=50,
                                opacity=0.7,
                                name='Earth')


        self.sync_trait('visibility', sphere.actor.actor)
        self.sync_trait('center', sphere.glyph.glyph_source.glyph_source)




if __name__ == '__main__':

    a = ActorViewer()
    a.configure_traits()

    


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev