예제 #1
0
파일: base.py 프로젝트: sjl421/code-2
 def __menu_default(self):
     extras = []
     if self.menu_helper is not None:
         extras = self.menu_helper.actions + self._extra_menu_items()
     menu_actions = [Separator()] + extras + \
                    [Separator(), self._HideShowAction, Separator()] + \
                    deepcopy(standard_menu_actions)
     return Menu( *menu_actions)
    def _menu_default(self):
        """ Standard menus for network nodes """

        menu_actions = [Separator(), \
                        self._OpenFile]

        return Menu(*menu_actions)
    def _menu_default(self):
        """ Standard menus for network nodes """

        menu_actions = [Separator(), \
                        self._TracksRender, \
                        self._TrackVisLaunchAction]

        return Menu(*menu_actions)
예제 #4
0
    def _actions_default(self):
        """ Append a preferences action to the toolbar: this view of the
            engine is meant to be a powerful view giving access to
            all of Mayavi's functionality.
        """
        preferences_action = \
            Action(
                image=ImageResource('preferences.png',
                                     search_path=self._image_path),
                tooltip="Modify Mayavi's preferences",
                checked=False,
                defined_when='True',
                perform=preference_manager_view.dialog_view,
            )

        actions = super(EngineRichView, self)._actions_default()
        actions.extend((Separator(), preferences_action))
        return actions
예제 #5
0
def _buildAction(desc):
    global actions_doc
    from window import tcActionHandler
    if len(desc) == 0:
        return Separator()
    exec("tcActionHandler.%s = lambda self,i:self.chooseAction(i,'_on_%s')"%(desc["name"],desc["name"]))
    style = desc["name"].startswith("toggle") and "toggle" or "push"
    default = False
    if "default" in desc:
        default = desc["default"]
    desc["tooltip"] = desc["tooltip"].strip()
    action = Action(name=desc["name"].replace("_"," "), action=desc["name"],
                  tooltip=desc["tooltip"],
                  image=ImageResource(desc["name"]),
                  style=style,
                  checked=default)
    tcActionHandler.actions[desc["name"]] = action
    if not actions_doc is None:
        actions_doc += "\n**%s**:\n"%(desc["name"].replace("_"," ").strip())
        actions_doc += "\n.. image:: images/%s.png\n\n"%(desc["name"])
        actions_doc += desc["tooltip"] +"\n"
    return action
예제 #6
0
           children  = 'departments',
           label     = '=Departments',
           view      = no_view,
           add       = [ Department ] ),
 TreeNode( node_for  = [ Company ],
           auto_open = True,
           children  = 'employees',
           label     = '=Employees',
           view      = no_view,
           add       = [ Employee ] ),
 TreeNode( node_for  = [ Department ],
           auto_open = True,
           children  = 'employees',
           label     = 'name',
           menu      = Menu( NewAction,
                             Separator(),
                             DeleteAction,
                             Separator(),
                             RenameAction,
                             Separator(),
                             CopyAction, 
                             CutAction, 
                             PasteAction ),
           view      = View( [ 'name', '|<' ] ),
           add       = [ Employee ] ),
 TreeNode( node_for  = [ Employee ],
           auto_open = True,
           label     = 'name',
           menu      = Menu( NewAction,
                             Separator(),
                             Action( name   = 'Default title',
예제 #7
0
    def _actions_default(self):
        add_scene = \
            Action(
                image=ImageResource('add_scene.png',
                                            search_path=self._image_path),
                tooltip="Create a new scene",
                defined_when='True',
                enabled_when='True',
                perform=self._perform_new_scene,
            )

        add_source = \
            Action(
                image=ImageResource('add_source.png',
                                            search_path=self._image_path),
                tooltip="Add a data source",
                defined_when='True',
                enabled_when='len(scenes) > 0',
                perform=self._perform_add_source,
            )

        add_module = \
            Action(
                image=ImageResource('add_module.png',
                                            search_path=self._image_path),
                tooltip="Add a visualization module",
                defined_when='True',
                # isinstance doesn't work in enabled_when
                enabled_when=\
                    'current_selection is not None and'
                    '( hasattr(current_selection, "output_info")'
                    'or current_selection.__class__.__name__ =='
                    '"ModuleFilterAdderNode")',
                perform=self._perform_add_module,
            )

        add_filter = \
            Action(
                image=ImageResource('add_filter.png',
                                            search_path=self._image_path),
                tooltip="Add a processing filter",
                defined_when='True',
                enabled_when=\
                    'current_selection is not None and'
                    '( ( hasattr(current_selection, "output_info")'
                    ' and not current_selection.type in (" module", '
                    ' " module manager"))'
                    'or current_selection.__class__.__name__ =='
                    '"ModuleFilterAdderNode")',
                perform=self._perform_add_filter,
             )

        help = \
            Action(
                image=ImageResource('help-action.png',
                                            search_path=self._image_path),
                tooltip="Help on the Mayavi pipeline",
                defined_when='True',
                enabled_when='True',
                perform=open_help_index,
            )

        tvtk_docs = \
            Action(
                image=ImageResource('reader.png',
                                            search_path=self._image_path),
                tooltip="Search the VTK class browser",
                defined_when='True',
                enabled_when='True',
                perform=open_tvtk_docs,
            )

        record = \
            Action(
                image=ImageResource('record.png',
                                     search_path=self._image_path),
                tooltip="Start/Stop script recording",
                style='toggle',
                checked=False,
                defined_when='True',
                enabled_when='engine is not None',
                perform=self._perform_record,
            )

        # Check the record icon if the engine already has a recorder
        # set.
        if self.engine is not None and self.engine.recorder is not None:
            record.checked = True

        return [
            tvtk_docs,
            Separator(), add_scene, add_source, add_module, add_filter,
            Separator(), help, record
        ]
예제 #8
0
          auto_open=True,
          children='departments',
          label='=Departments',
          view=no_view,
          add=[Department]),
 TreeNode(node_for=[Company],
          auto_open=True,
          children='employees',
          label='=Employees',
          view=no_view,
          add=[Employee]),
 TreeNode(node_for=[Department],
          auto_open=True,
          children='employees',
          label='name',
          menu=Menu(NewAction, Separator(), DeleteAction, Separator(),
                    RenameAction, Separator(), CopyAction, CutAction,
                    PasteAction),
          view=View(['name', '|<']),
          add=[Employee]),
 TreeNode(node_for=[Employee],
          auto_open=True,
          label='name',
          menu=Menu(
              NewAction, Separator(),
              Action(name='Default title',
                     action='object.default_title'),
              Action(
                  name='Department',
                  action='handler.employee_department(editor,object)'),
              Separator(), CopyAction, CutAction, PasteAction,
예제 #9
0
class PlotOMaticHandler(Controller):
    # ------------ Menu related --------------------
    exit_action = Action(name='&Exit', action='exit')
    save_session_action = Action(name='&Open Session',
                                 action='open_session',
                                 accelerator='Ctrl+O')
    open_session_action = Action(name='&Save Session',
                                 action='save_session',
                                 accelerator='Ctrl+S')

    file_menu = Menu(exit_action,
                     Separator(),
                     save_session_action,
                     open_session_action,
                     name='&File')

    def exit(self, uii):
        print 'Exit called, really should implement this'

    def save_session(self, uii):
        filename = save_file(
            wildcard=
            'Plot-o-matic session (*.plot_session)|*.plot_session|All files (*)|*',
            file_name='my_session.plot_session',
            message='Save session')
        if filename != '':
            print "Saving session as '%s'" % filename
            session = uii.object.get_config()
            fp = open(filename, 'w')
            yaml.safe_dump(session, fp, default_flow_style=False)
            fp.close()

    def open_session(self, uii):
        filename = open_file(
            wildcard=
            'Plot-o-matic session (*.plot_session)|*.plot_session|All files (*)|*',
            file_name='my_session.plot_session',
            message='Open session')
        if filename != '':
            print "Opening session '%s'" % filename
            fp = open(filename, 'r')
            session = yaml.load(fp)
            fp.close()
            uii.object.set_config(session)

    clear_data_action = Action(name='&Clear Data',
                               action='clear_data',
                               accelerator='Ctrl+W')
    save_data_action = Action(name='&Save Data Set',
                              action='save_data',
                              accelerator='Ctrl+Shift+S')
    open_data_action = Action(name='&Open Data Set',
                              action='open_data',
                              accelerator='Ctrl+Shift+O')

    data_menu = Menu(clear_data_action,
                     Separator(),
                     save_data_action,
                     open_data_action,
                     name='&Data')

    def clear_data(self, uii):
        uii.object.variables.clear()

    def save_data(self, uii):
        filename = save_file(
            wildcard=
            'Plot-o-matic data set (*.plot_data)|*.plot_data|All files (*)|*',
            file_name='my_data.plot_data',
            message='Save data set')
        if filename != '':
            uii.object.variables.save_data_set(filename)
            print "Saved data set '%s'" % filename

    def open_data(self, uii):
        filename = open_file(
            wildcard=
            'Plot-o-matic data set (*.plot_data)|*.plot_data|All files (*)|*',
            file_name='my_data.plot_data',
            message='Open data set')
        if filename != '':
            uii.object.variables.open_data_set(filename)
            print "Opened data set '%s'" % filename

    # ------------ Tree related --------------------

    remove_io_driver_action = Action(
        name='Remove', action='handler.remove_io_driver(editor,object)')
    add_io_driver_actions_menu = Instance(Menu)

    remove_decoder_action = Action(
        name='Remove', action='handler.remove_decoder(editor,object)')
    add_decoder_actions_menu = Instance(Menu)

    remove_viewer_action = Action(
        name='Remove', action='handler.remove_viewer(editor,object)')
    add_viewer_actions_menu = Instance(Menu)

    refresh_tree_action = Action(name='Refresh',
                                 action='handler.refresh_tree(editor)')

    def refresh_tree(self, editor):
        editor.update_editor()

    def _add_io_driver_actions_menu_default(self):
        actions = []
        for io_driver_plugin in find_io_driver_plugins():
            actions += [
                Action(name=io_driver_plugin.__name__,
                       action='handler.add_io_driver(editor,object,"%s")' %
                       io_driver_plugin.__name__)
            ]
        return Menu(name='Add', *actions)

    def remove_io_driver(self, editor, io_driver_object):
        io_driver_list = editor._menu_parent_object
        io_driver_list._remove_io_driver(io_driver_object)
        editor.update_editor()

    def add_io_driver(self, editor, io_driver_list, new_io_driver_name):
        new_io_driver = get_io_driver_plugin_by_name(new_io_driver_name)()
        io_driver_list._add_io_driver(new_io_driver)
        editor.update_editor()

    def _add_decoder_actions_menu_default(self):
        actions = []
        for decoder_plugin in find_decoder_plugins():
            actions += [
                Action(name=decoder_plugin.__name__,
                       action='handler.add_decoder(editor,object,"%s")' %
                       decoder_plugin.__name__)
            ]
        return Menu(name='Add', *actions)

    def remove_decoder(self, editor, decoder_object):
        parent_io_driver = editor._menu_parent_object
        parent_io_driver._remove_decoder(decoder_object)
        editor.update_editor()

    def add_decoder(self, editor, io_driver, decoder_name):
        io_driver_list = editor._menu_parent_object
        new_decoder = get_decoder_plugin_by_name(decoder_name)()
        io_driver._add_decoder(new_decoder)
        editor.update_editor()

    def _add_viewer_actions_menu_default(self):
        actions = []
        for viewer_plugin in find_viewer_plugins():
            actions += [
                Action(name=viewer_plugin.__name__,
                       action='handler.add_viewer(editor,object,"%s")' %
                       viewer_plugin.__name__)
            ]
        return Menu(name='Add', *actions)

    def remove_viewer(self, editor, viewer_object):
        viewers = editor._menu_parent_object.viewers_instance
        viewers._remove_viewer(viewer_object)
        editor.update_editor()

    def add_viewer(self, editor, object, viewer_name):
        new_viewer = get_viewer_plugin_by_name(viewer_name)()
        object.viewers_instance._add_viewer(new_viewer)
        editor.update_editor()
예제 #10
0
파일: base.py 프로젝트: sjl421/code-2
CopyAction   = Action(name         = 'Copy',
                      action       = 'editor._menu_copy_node',
                      enabled_when = 'editor._is_copyable(object)' )
CutAction    = Action(name         = 'Cut',
                      action       = 'editor._menu_cut_node',
                      enabled_when = 'editor._is_cutable(object)' )
PasteAction  = Action(name         = 'Paste',
                      action       = 'editor._menu_paste_node',
                      enabled_when = 'editor._is_pasteable(object)' )
DeleteAction = Action(name         = 'Delete',
                      action       = 'editor._menu_delete_node',
                      enabled_when = 'editor._is_deletable(object)' )
RenameAction = Action(name         = 'Rename',
                      action       = 'editor._menu_rename_node',
                      enabled_when = 'editor._is_renameable(object)' )
standard_menu_actions = [Separator(), CutAction, CopyAction, PasteAction,
                         Separator(),
                         RenameAction, DeleteAction, Separator(), 
                        ]


######################################################################
# `Base` class.
######################################################################
class Base(TreeNodeObject):
    # The version of this class.  Used for persistence.
    __version__ = 0
    
    ########################################
    # Traits
예제 #11
0
    def __init__(self, *args, **kargs):
        super(StonerPlot, self).__init__(*args, **kargs)
        self.data = numpy.zeros((2, 2))
        acols = [(self.column_headers[i], i)
                 for i in range(len(self.column_headers))]
        acols[:0] = [("index", "index")]
        self.adapter = ArrayAdapter()
        self.adapter.columns = acols
        self.plotgroup = Group(HGroup(
            VGroup(
                Item('xc',
                     label='X Column',
                     editor=CheckListEditor(name='column_headers')),
                Item('xm', label="X Scale")),
            VGroup(
                Item('yc',
                     label='Y Column',
                     editor=CheckListEditor(name='column_headers')),
                Item('ym', label="Y scale")), Item('p_type',
                                                   label='Plot Type')),
                               HGroup(
                                   Item('color',
                                        label="Colour",
                                        style="simple",
                                        width=75,
                                        visible_when='"scatter" in p_type'),
                                   Item('line_color',
                                        label="Line Colour",
                                        style="simple",
                                        visible_when='outline_width>0',
                                        width=75),
                                   Item('marker',
                                        label="Marker",
                                        visible_when='"scatter" in p_type'),
                                   Item('line_style',
                                        label='Line Style',
                                        visible_when="'line' in p_type"),
                                   Item('marker_size',
                                        label="Marker Size",
                                        visible_when='"scatter" in p_type'),
                                   Item('outline_width', label="Line Width")),
                               Item('plot',
                                    editor=ComponentEditor(),
                                    show_label=False),
                               label="Plot",
                               orientation="vertical")
        self.datagroup = HGroup(Item(
            'data',
            show_label=False,
            style='readonly',
            editor=TabularEditor(adapter=self.adapter)),
                                Item('metadata',
                                     editor=ValueEditor(),
                                     show_label=False,
                                     width=0.25),
                                label="Data")
        self.tabs = Tabbed(self.plotgroup,
                           self.datagroup,
                           orientation="horizontal")

        self.menubar = MenuBar(
            Menu(
                Action(name='E&xit',
                       accelerator="Ctrl+Q",
                       tooltip="E&xit",
                       action='_on_close'),
                Separator(),
                Action(name="&Open",
                       accelerator="Ctrl+O",
                       tooltip="&Open Data File",
                       action="load"),  # these callbacks
                Action(name="&Close",
                       accelerator="Ctrl+W",
                       tooltip="&Close Plot",
                       action="close_plot"),  # these callbacks
                name="File"))

        self._paint()
예제 #12
0
class PlotOMaticHandler(Controller):
  # ------------ Menu related --------------------
  exit_action = Action(name='&Exit', action='exit')
  save_session_action = Action(name='&Open Session', action='open_session')
  open_session_action = Action(name='&Save Session', action='save_session')

  file_menu = Menu(
      exit_action,
      Separator(),
      save_session_action,
      open_session_action,
      name = '&File'
  )

  def exit(self, uii):
    print 'Exit called, really should implement this'

  def save_session(self, uii):
    print 'save'
    print pickle.dumps(uii.object.viewers)

  def open_session(self, uii):
    print 'open'
  
  clear_data_action = Action(name = '&Clear Data', action='clear_data')
  save_data_action = Action(name = '&Save Data Set', action='save_data')
  open_data_action = Action(name = '&Open Data Set', action='open_data')

  data_menu = Menu(
      clear_data_action,
      Separator(),
      save_data_action,
      open_data_action,
      name = '&Data'
  )

  def clear_data(self, uii):
    uii.object.variables.clear()

  def save_data(self, uii):
    filename = save_file()
    if filename != '':
      uii.object.variables.save_data_set(filename)
      print "Saved data set as", filename

  def open_data(self, uii):
    filename = open_file()
    if filename != '':
      uii.object.variables.open_data_set(filename)
      print "Opened data set ", filename


  # ------------ Tree related --------------------

  remove_io_driver_action = Action(name='Remove', action='handler.remove_io_driver(editor,object)')
  add_io_driver_actions_menu = Instance(Menu)

  remove_decoder_action = Action(name='Remove', action='handler.remove_decoder(editor,object)')
  add_decoder_actions_menu = Instance(Menu)

  remove_viewer_action = Action(name='Remove', action='handler.remove_viewer(editor,object)')
  add_viewer_actions_menu = Instance(Menu)

  def _add_io_driver_actions_menu_default(self):
    actions = []
    for io_driver_plugin in find_io_driver_plugins():
      actions += [Action(
        name = io_driver_plugin.__name__,
        action = 'handler.add_io_driver(editor,object,"%s")' % io_driver_plugin.__name__
      )]
    return Menu(name = 'Add', *actions)

  def remove_io_driver(self, editor, io_driver_object):
    io_driver_list = editor._menu_parent_object
    io_driver_list._remove_io_driver(io_driver_object)
    editor.update_editor()

  def add_io_driver(self, editor, io_driver_list, new_io_driver_name):
    new_io_driver = get_io_driver_plugin_by_name(new_io_driver_name)()
    io_driver_list._add_io_driver(new_io_driver)
    editor.update_editor()

  def _add_decoder_actions_menu_default(self):
    actions = []
    for decoder_plugin in find_decoder_plugins():
      actions += [Action(
        name = decoder_plugin.__name__,
        action = 'handler.add_decoder(editor,object,"%s")' % decoder_plugin.__name__
      )]
    return Menu(name = 'Add', *actions)

  def remove_decoder(self, editor, decoder_object):
    parent_io_driver = editor._menu_parent_object
    parent_io_driver._remove_decoder(decoder_object)
    editor.update_editor()

  def add_decoder(self, editor, io_driver, decoder_name):
    io_driver_list = editor._menu_parent_object
    new_decoder = get_decoder_plugin_by_name(decoder_name)(variables = io_driver_list.variables)
    io_driver._add_decoder(new_decoder)
    editor.update_editor()
    
  def _add_viewer_actions_menu_default(self):
    actions = []
    for viewer_plugin in find_viewer_plugins():
      actions += [Action(
        name = viewer_plugin.__name__,
        action = 'handler.add_viewer(editor,object,"%s")' % viewer_plugin.__name__
      )]
    return Menu(name = 'Add', *actions)

  def remove_viewer(self, editor, viewer_object):
    viewers = editor._menu_parent_object.viewers_instance
    viewers._remove_viewer(viewer_object)
    editor.update_editor()

  def add_viewer(self, editor, object, viewer_name):
    new_viewer = get_viewer_plugin_by_name(viewer_name)()
    object.viewers_instance._add_viewer(new_viewer)
    editor.update_editor()
예제 #13
0
             auto_open=True,
             children='departments',
             label='=Departments',
             view=no_view,
             add=[Department]),
    TreeNode(node_for=[Company],
             auto_open=True,
             children='employees',
             label='=Employees',
             view=no_view,
             add=[Employee]),
    TreeNode(node_for=[Department],
             auto_open=True,
             children='employees',
             label='name',
             menu=Menu(NewAction, Separator(), DeleteAction, Separator(
             ), RenameAction, Separator(), CopyAction, CutAction, PasteAction),
             view=View(Group('name', orientation='vertical', show_left=True)),
             add=[Employee]),
    TreeNode(node_for=[Employee],
             auto_open=True,
             label='name',
             menu=Menu(NewAction, Separator(), def_title_action, dept_action,
                       Separator(), CopyAction, CutAction, PasteAction,
                       Separator(), DeleteAction, Separator(), RenameAction),
             view=employee_view)
])
# The main view
view = View(
           Group(
               Item(