Traitsui and mlab

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Traitsui and mlab

Jan Kurzawski
Hi all,


I am new to Traitsui but i've managed to prepare a code with mlab window. The only problem is that i want 1 window to popup and all the properties i want to change are in seperate one. Could you give me an advice what should I add? Should i add something to the view? I was looking at the example of putting mlab window inside traitsui but still i cannot combine it with the sliders.

Here is the code

from traits.api import Instance, HasTraits, Range, Bool
from traitsui.api import Item, View, Group
from mayavi.modules.api import IsoSurface
import pickle
import pprint





class PropertiesControl(HasTraits):
      # The mayavi element we want to control
      iso_surface = Instance(IsoSurface)

      # The opacity of the mayavi element
      visibility = Bool(True)
      opacity = Range(low=0.1, high=1, value=0.1)

      def __init__(self, iso_surface, **traits):
          super(PropertiesControl, self).__init__(**traits)
          self.iso_surface = iso_surface

          # Link the opacity of the mayavi element with the opacity trait
          self.sync_trait('visibility', iso_surface.actor.actor)
          self.sync_trait('opacity', iso_surface.actor.property)

      traits_view = View(
          Group('visibility','_','opacity'),dock='horizontal',height=500
      )

if __name__ == '__main__':
   from mayavi import mlab
   iso_surface = mlab.test_contour3d()
   visibility_control = PropertiesControl(iso_surface)
   visibility_control.configure_traits()


Best,
Jan


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Traitsui and mlab

Corran Webster
Hi Jan,

I think you can find an example doing something like what you want here:


The key is that you need to have a SceneModel instance in a trait which is displayed in a traitsUI View with a SceneEditor.

-- Corran


On Thu, Nov 29, 2012 at 6:56 AM, Jan Kurzawski <[hidden email]> wrote:
Hi all,


I am new to Traitsui but i've managed to prepare a code with mlab window. The only problem is that i want 1 window to popup and all the properties i want to change are in seperate one. Could you give me an advice what should I add? Should i add something to the view? I was looking at the example of putting mlab window inside traitsui but still i cannot combine it with the sliders.

Here is the code

from traits.api import Instance, HasTraits, Range, Bool
from traitsui.api import Item, View, Group
from mayavi.modules.api import IsoSurface
import pickle
import pprint





class PropertiesControl(HasTraits):
      # The mayavi element we want to control
      iso_surface = Instance(IsoSurface)

      # The opacity of the mayavi element
      visibility = Bool(True)
      opacity = Range(low=0.1, high=1, value=0.1)

      def __init__(self, iso_surface, **traits):
          super(PropertiesControl, self).__init__(**traits)
          self.iso_surface = iso_surface

          # Link the opacity of the mayavi element with the opacity trait
          self.sync_trait('visibility', iso_surface.actor.actor)
          self.sync_trait('opacity', iso_surface.actor.property)

      traits_view = View(
          Group('visibility','_','opacity'),dock='horizontal',height=500
      )

if __name__ == '__main__':
   from mayavi import mlab
   iso_surface = mlab.test_contour3d()
   visibility_control = PropertiesControl(iso_surface)
   visibility_control.configure_traits()


Best,
Jan


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


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