class MayaviScene(DecoratedScene): """ A scene UI, similar to a decorated scene, but with more buttons. """ image_search_path = [join(resource_path(), 'images'), ] ########################################################################## # Non-public interface. ########################################################################## def show_engine(self): """ Open the engine view corresponding to the engine of the scene. """ from enthought.mayavi.core.registry import registry from enthought.mayavi.core.ui.engine_rich_view import EngineRichView try: engine = registry.find_scene_engine(self) except TypeError: error('This scene is not managed by Mayavi') return EngineRichView(engine=engine).scene_editing_view(scene=self) ###################################################################### # Trait handlers. ###################################################################### def _actions_default(self): actions = [ Group( Action(tooltip="View the Mayavi pipeline", image=ImageResource('m2', search_path=self.image_search_path), on_perform=self.show_engine, ), ), ] actions.extend(DecoratedScene._actions_default(self)) return actions
class PreferenceManagerView(PreferencesManager): """ A preference manager UI for Mayavi, to be used outside of Envisage. """ # Path used to search for images _image_path = [join(resource_path(), 'images'), ] # The icon of the dialog icon = ImageResource('preferences.ico', search_path=_image_path) # The preference pages displayed pages = List(PreferencesPage) def _pages_default(self): return [ MayaviRootPreferencesPage( preferences=preference_manager.root.preferences), MayaviMlabPreferencesPage( preferences=preference_manager.mlab.preferences), ] def dialog_view(self): """ Poor-man's subclassing of view to overload size. """ view = self.trait_view() view.width = 0.7 view.height = 0.5 view.title = 'Mayavi preferences' view.icon = self.icon ui = self.edit_traits( view=view, scrollable=True, id='enthought.mayavi.preferences.preference_view') return ui def _get_root(self): """ Subclass the root getter, to work outside of envisage, with no well-defined root. """ root = PreferencesNode(page=self.pages[0]) for page in self.pages: root.append(PreferencesNode(page=page)) return root def apply(self): super(PreferenceManagerView, self).apply() for page in self.pages: page.preferences.save()
def mk_scene_icon(): icon_path = os.path.join(resource_path(), 'images', 'scene.ico') return ImageResource(icon_path)
def mk_scene_icon(): icon_path = os.path.join(resource_path(), "images", "scene.ico") return ImageResource(icon_path)
def __icon_path_default(self): return resource_path()