class MDDModelerPerspective(Perspective): ''' ''' name = 'MDD' show_editor_area = True contents = [ PerspectiveItem(id='pychron.modeler.data_directory', # width = 0.65 ), PerspectiveItem(id='pychron.modeler.summary_view', # width = 0.65 ), PerspectiveItem( id='pychron.modeler.info_view', # width = 0.65 relative_to='pychron.modeler.summary_view', position='with'), PerspectiveItem( id='pychron.modeler.notes_view', relative_to='pychron.modeler.summary_view', # width = 0.65 position='bottom'), PerspectiveItem( id='pychron.modeler.process_view', relative_to='pychron.modeler.notes_view', # width = 0.65 position='with') ]
class LorenzPerspective(Perspective): """ A perspective containing the default Lorenz views. """ name = 'Lorenz' show_editor_area = False contents = [ PerspectiveItem(id='lorenz.data'), PerspectiveItem(id='lorenz.plot2d') ]
class LorenzPerspective(Perspective): """ A perspective containing the default Lorenz views. """ name = "Lorenz" show_editor_area = False contents = [ PerspectiveItem(id="lorenz.data"), PerspectiveItem(id="lorenz.plot2d"), ]
class BarPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = "Bar" # Should the editor area be shown in this perspective? show_editor_area = False # The contents of the perspective. contents = [ PerspectiveItem(id="Green"), PerspectiveItem(id="Black", position="bottom", relative_to="Green"), ]
def get_developer_perspective(**traits): return Perspective(id=ID + '.perspective.developer', name='Developer Tools', show_editor_area=False, contents=[ PerspectiveItem( id=ID + '.file_browser', position='left', ), PerspectiveItem( id=ID + '.app_monitor', position='right', ) ])
class BarPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = 'Bar' # Should the editor area be shown in this perspective? show_editor_area = False # The contents of the perspective. contents = [ PerspectiveItem(id='Green'), PerspectiveItem(id='Black', position='bottom', relative_to='Green') ]
class FooPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = "Foo" # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem(id="Blue", position="left"), PerspectiveItem(id="Red", position="with", relative_to="Blue"), PerspectiveItem(id="Green", position="top"), ]
class FooPerspective(Perspective): """ An example perspective. """ # The perspective's name. name = 'Foo' # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem(id='Blue', position='left'), PerspectiveItem(id='Red', position='with', relative_to='Blue'), PerspectiveItem(id='Green', position='top') ]
def _contents_default(self): # The contents of the perspective. Add the views here with position contents = [ PerspectiveItem(id=CFFVIEW, position='left', width=0.6), PerspectiveItem(id=ENGINE_VIEW, position='bottom', relative_to=CFFVIEW), PerspectiveItem(id=SHELL_VIEW, position='bottom', height=0.2), # XXX: deactivate mayavi views per default as not to confuse end-users too much #PerspectiveItem(id=CURRENT_SELECTION_VIEW, position='bottom', # relative_to=ENGINE_VIEW), ] return contents
class IBVModelSpecifyPerspective(Perspective): """ An default perspective for the app. """ # The perspective's name. name = 'Specify IBV Model' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem(id=IBVMODEL_VIEW, position='top'), PerspectiveItem(id=TSTEPPER_VIEW, position='bottom'), ]
class DeveloperPerspective(Perspective): """ The Developer perspective. This perspective is intented to contain views and editors useful for inspecting and debugging a running Envisage application. """ # The root of all view Ids in this package. ROOT = 'envisage.developer.ui.view' # View Ids. APPLICATION_BROWSER_VIEW = ROOT + '.application_browser_view' EXTENSION_REGISTRY_BROWSER_VIEW = ROOT + '.extension_registry_browser_view' SERVICE_REGISTRY_BROWSER_VIEW = ROOT + '.service_registry_browser_view' # The perspective's name. name = 'Developer' # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem( id = APPLICATION_BROWSER_VIEW, position = 'left' ), PerspectiveItem( id = EXTENSION_REGISTRY_BROWSER_VIEW, position = 'bottom', relative_to = APPLICATION_BROWSER_VIEW ), PerspectiveItem( id = 'Python', position = 'bottom', ), PerspectiveItem( id = SERVICE_REGISTRY_BROWSER_VIEW, position = 'right', ), ]
class TestPerspective(Perspective): """ An default perspective for the app. """ # The perspective's name. name = 'Test' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # View IDs. BROWSER_VIEW = 'tvtk.plugins.browser.browser_view.BrowserView' SHELL_VIEW = 'envisage.plugins.python_shell.view.python_shell_view.PythonShellView' # The contents of the perspective. contents = [ PerspectiveItem(id=BROWSER_VIEW, position='left'), PerspectiveItem(id=SHELL_VIEW, position='bottom') ]
def _contents_default(self): contents = [ PerspectiveItem(id=ENGINE_VIEW, position='left'), PerspectiveItem(id=CURRENT_SELECTION_VIEW, position='bottom', relative_to=ENGINE_VIEW), PerspectiveItem(id=SHELL_VIEW, position='bottom'), ] show_logger = True if ETSConfig.toolkit == 'wx': # XXX: Bugware: avoid a crash in Wx with the logger import wx if wx.__version__.split('.')[:2] == ['2', '6']: show_logger = False if show_logger: contents.append( PerspectiveItem(id=LOGGER_VIEW, position='with', relative_to=SHELL_VIEW)) return contents
class IBVModelAnalyzePerspective(Perspective): """ An default perspective for the app. """ # The perspective's name. name = 'Analyze IBV Model' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # The contents of the perspective. contents = [ PerspectiveItem(id=IBVMODEL_VIEW, position='top'), PerspectiveItem(id=RTRACEMNGR_VIEW, relative_to=IBVMODEL_VIEW, position='bottom'), PerspectiveItem(id=TLOOP_VIEW, relative_to=RTRACEMNGR_VIEW, position='bottom'), ]
class ExplorerPerspective(Perspective): """ An default perspective for the app. """ # The perspective's name. name = 'Explorer3D' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # View IDs. EXPLORER_VIEW = 'explorer3d.Explorer3D' # The contents of the perspective. contents = [ PerspectiveItem(id=EXPLORER_VIEW, position='left'), ]
class TLoopPerspective(Perspective): """ An default perspective for the app. """ # The perspective's name. name = 'Time Loop' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # View IDs. TLOOPMNGR_VIEW = 'ibvpy.plugins.tloop_service.tloop_service' # The contents of the perspective. contents = [ PerspectiveItem(id=TLOOPMNGR_VIEW, position='left'), ]
class RTracePerspective(Perspective): """ An default perspective for the app. """ # The perspective's name. name = 'RTrace' # Should this perspective be enabled or not? enabled = True # Should the editor area be shown in this perspective? show_editor_area = True # View IDs. RTRACEMNGR_VIEW = 'ibvpy.plugins.rtrace_service.rtrace_service' # The contents of the perspective. contents = [ PerspectiveItem(id=RTRACEMNGR_VIEW, position='left'), ]
class ApplicationWindow(WorkbenchWindow): """ The ExampleUndoWindow class is a workbench window that contains example editors that demonstrate the use of the undo framework. """ ########################################################################### # ApplicationWindow traits. ########################################################################### #### Private interface #################################################### # fixme: We need complete arguments as to why these need to be traits. # I can see the benefit of reusing the same actions in different # locations in the UI (menu, toolbar, etc.) and ensuring there # names/implementations are uniform. But it is also verbose # and results in a lot of boiler plate. The alternative is just # to create the actions on the fly when we need. ### Actions ############################################################### # The action that exits the application. _exit_action = Instance(Action) # Action for creating a new project, saving old one if desired. _new_project_action = Instance(Action) ### Menus ################################################################# # The File menu. _file_menu = Instance(MenuManager) # The Edit menu. _edit_menu = Instance(MenuManager) # Macro management menu. _macro_menu = Instance(MenuManager) # The View menu for managing perspectives. _view_menu = Instance(MenuManager) ########################################################################### # WorkbenchWindow interface. ########################################################################### perspectives = [ Perspective(name='Edit', contents=[ PerspectiveItem(id='Search', position='left'), PerspectiveItem(id='Function Documentation', relative_to='Search', position='bottom'), PerspectiveItem(id='Experiement Code', position='bottom'), PerspectiveItem(id='Context', position='right') ]), Perspective(name='Debug', contents=[PerspectiveItem(id='Debug', position='left')]) ] #### Trait initializers ################################################### def _editor_manager_default(self): """ Use our custom editor manager be default. """ return ApplicationEditorManager(window=self) def _menu_bar_manager_default(self): """ Setup the menus for the application. """ return MenuBarManager(self._file_menu, self._edit_menu, self._macro_menu, self._view_menu, window=self) def _tool_bar_manager_default(self): """ Trait initialiser. """ return ToolBarManager(self._exit_action, show_tool_names=False) ########################################################################## # ApplicationWindow interface. ########################################################################## #### Trait initializers ################################################## def _views_default(self): """ Trait initializer. """ # Using an initializer makes sure that every window instance gets its # own view instances (which is necessary since each view has a # reference to its toolkit-specific control etc.). # fixme: Ask Martin why he put this here instead of at the top. from pyface.workbench.debug.api import DebugView # fixme: This doesn't appear to be updating. debug_view = DebugView(window=self) # fixme: I am quite sure this is not the way these views should # be set up, but it is the easiest spot for now. # Create a view of the search window. search_view = FunctionSearchView(name='Search', window=self) # Create a view of the html window. doc_view = TraitsUIView(name='Function Documentation', obj=self.workbench.app.html_window, window=self) # Create a view of the project context. context_view = ExperimentContextView( name='Context', obj=self.workbench.app.project.active_experiment, window=self) # Create a view of the project code. experiment_code_view = ExperimentCodeView( name='Experiment Code', obj=self.workbench.app.project.active_experiment, window=self) return [ debug_view, search_view, doc_view, context_view, experiment_code_view ] #### Menu initializers ################################################### def __file_menu_default(self): """ Initialize the File Menus. """ new_group = Group( # Create a new python script. #NewScriptAction(), # New Experiement. Ctrl-N should map here. #NewExperimentAction(), # Open an entirely new Project, closing the current one # if necessary. self._new_project_action) file_group = Group( new_group, # OpenAction() # CloseAction() ) exit_group = Group(self._exit_action) return MenuManager(new_group, exit_group, name="&File", id='FileMenu') def __edit_menu_default(self): """ Initialize the Edit Menus. """ undo_manager = self.workbench.undo_manager # fixme: Add cut/copy/paste. # fixme: Add Ctrl-Z Ctrl-Y short cuts here. undo_group = Group(UndoAction(undo_manager=undo_manager), RedoAction(undo_manager=undo_manager)) return MenuManager(undo_group, name="&Edit", id='EditMenu') def __macro_menu_default(self): """ The Undo menu handles Undo/Redo and macro recording. fixme: Undo/Redo should go to the edit menu. Macro recording should go somewhere else. """ undo_manager = self.workbench.undo_manager script_group = Group(BeginRecordingAction(undo_manager=undo_manager), EndRecordingAction(undo_manager=undo_manager), ClearRecordingAction(undo_manager=undo_manager)) return MenuManager(script_group, name="&Macro", id="MacroMenu") def __view_menu_default(self): """ The View menu allows you to change the visible perspectives. """ return ViewMenuManager(name='&View', id='ViewMenu', window=self) ### Action Defaults ###################################################### def __exit_action_default(self): """ Trait initialiser. """ return Action(name="E&xit", on_perform=self.workbench.exit) def __new_project_action_default(self): """ Trait initialiser. """ return Action(name="New Project", on_perform=self._new_project) def _new_project(self): """ Implementation for creating a new project. This can contain UI code. """ # fixme: Ask user it they want to save. If so, do it. self.workbench.app.project.save() # Close any editors associated with the old project. # (Perhaps) all of them. # fixme, we just close the current experiment. old_editor = self.get_editor(self.workbench.app.project) old_editor.close() # Create a new project and set it as the application project. self.workbench.app.project = Project() self.workbench.app.project.add_experiment(Experiment()) # Bring it up in the editor. self.edit(self.workbench.app.project) # fixme: This is temporary until we put the script into a view. #@on_trait_change('workbench.undo_manager.script_updated') #def _on_script_updated(self, undo_manager): # if str(undo_manager) == "<undefined>": # return # # script = undo_manager.script # # if script: # print script, # else: # print "Script empty" def _active_editor_changed(self, old, new): """ Handle any UI related changes when a new editor becomes active. For now, we simply swap out the Undo Stacks. """ # Tell the undo manager about the new command stack. if old is not None: old.command_stack.undo_manager.active_stack = None if new is not None: new.command_stack.undo_manager.active_stack = new.command_stack
class ExampleWorkbenchWindow(WorkbenchWindow): """A simple example of using the workbench window.""" #### 'WorkbenchWindow' interface ########################################## # The available perspectives. perspectives = [ Perspective(name='Foo', contents=[ PerspectiveItem(id='Black', position='bottom'), PerspectiveItem(id='Debug', position='left') ]), Perspective(name='Bar', contents=[PerspectiveItem(id='Debug', position='left')]) ] #### Private interface #################################################### # The Exit action. _exit_action = Instance(Action) # The New Person action. _new_person_action = Instance(Action) ########################################################################### # 'ApplicationWindow' interface. ########################################################################### def _editor_manager_default(self): """ Trait initializer. Here we return the replacement editor manager. """ return ExampleEditorManager() def _menu_bar_manager_default(self): """Trait initializer.""" file_menu = MenuManager(self._new_person_action, self._exit_action, name='&File', id='FileMenu') view_menu = ViewMenuManager(name='&View', id='ViewMenu', window=self) user_menu = UserMenuManager(id='UserMenu', window=self) return MenuBarManager(file_menu, view_menu, user_menu, window=self) def _tool_bar_manager_default(self): """Trait initializer.""" return ToolBarManager(self._exit_action, show_tool_names=False) ########################################################################### # 'WorkbenchWindow' interface. ########################################################################### def _views_default(self): """Trait initializer.""" from secured_debug_view import SecuredDebugView return [SecuredDebugView(window=self)] ########################################################################### # Private interface. ########################################################################### def __exit_action_default(self): """Trait initializer.""" return Action(name='E&xit', on_perform=self.workbench.exit) def __new_person_action_default(self): """Trait initializer.""" # Create the action and secure it with the appropriate permission. act = Action(name='New Person', on_perform=self._new_person) act = SecureProxy(act, permissions=[NewPersonPerm]) return act def _new_person(self): """Create a new person.""" self.workbench.edit(Person(name='New', age=100))
class ExampleWorkbenchWindow(WorkbenchWindow): """ A simple example of using the workbench window. """ #### 'WorkbenchWindow' interface ########################################## # The available perspectives. perspectives = [ Perspective( name = 'Foo', contents = [ PerspectiveItem(id='Black', position='bottom', height=0.1), PerspectiveItem(id='Debug', position='left', width=0.25) ] ), Perspective( name = 'Bar', contents = [ PerspectiveItem(id='Black', position='top'), PerspectiveItem(id='Blue', position='bottom'), PerspectiveItem(id='Green', position='left'), PerspectiveItem(id='Red', position='right'), PerspectiveItem(id='Debug', position='left') ] ) ] #### 'ExampleWorkbenchWindow' interface ################################### # The view factories. # # fixme: This should be part of the standadr 'WorkbenchWindow'! view_factories = List(Callable) #### Private interface #################################################### # The Exit action. _exit_action = Instance(Action) # The New Person action. _new_person_action = Instance(Action) ########################################################################### # 'ApplicationWindow' interface. ########################################################################### #### Trait initializers ################################################### def _editor_manager_default(self): """ Trait initializer. Here we return the replacement editor manager. """ return ExampleEditorManager() def _menu_bar_manager_default(self): """ Trait initializer. """ file_menu = MenuManager( self._new_person_action, self._exit_action, name='&File', id='FileMenu' ) view_menu = ViewMenuManager(name='&View', id='ViewMenu', window=self) return MenuBarManager(file_menu, view_menu, window=self) def _tool_bar_managers_default(self): """ Trait initializer. """ # Add multiple (albeit identical!) tool bars just to show that it is # allowed! tool_bar_managers = [ ToolBarManager( self._exit_action, show_tool_names = False, name=str(i) ) for i in range(5) ] return tool_bar_managers ########################################################################### # 'WorkbenchWindow' interface. ########################################################################### #### Trait initializers ################################################### def _view_factories_default(self): """ Trait initializer. """ from pyface.workbench.debug.api import DebugView return [DebugView, BlackView, BlueView, GreenView, RedView, YellowView] def _views_default(self): """ Trait initializer. """ # Using an initializer makes sure that every window instance gets its # own view instances (which is necessary since each view has a # reference to its toolkit-specific control etc.). return [factory(window=self) for factory in self.view_factories] ########################################################################### # Private interface. ########################################################################### def __exit_action_default(self): """ Trait initializer. """ return Action(name='E&xit', on_perform=self.workbench.exit) def __new_person_action_default(self): """ Trait initializer. """ return Action(name='New Person', on_perform=self._new_person) def _new_person(self): """ Create a new person. """ from person import Person self.workbench.edit(Person(name='New', age=100)) return