How to use the traitsui.menu.Action function in traitsui

To help you get started, we’ve selected a few traitsui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enthought / traitsui / traitsui / qt4 / tree_editor.py View on Github external
from traitsui.menu import Menu, Action, Separator

from clipboard import clipboard, PyMimeData
from editor import Editor
from helper import pixmap_cache

logger = logging.getLogger(__name__)

#-------------------------------------------------------------------------
#  The core tree node menu actions:
#-------------------------------------------------------------------------
from traitsui.ui_traits import SequenceTypes


NewAction = 'NewAction'
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)')

#-------------------------------------------------------------------------
github enthought / traitsui / traitsui / wx / tree_editor.py View on Github external
object = self._data[1]
        items = []
        add = node.get_add(object)
        if len(add) > 0:
            for klass in add:
                prompt = False
                if isinstance(klass, tuple):
                    klass, prompt = klass
                add_node = self._node_for_class(klass)
                if add_node is not None:
                    class_name = klass.__name__
                    name = add_node.get_name(object)
                    if name == '':
                        name = class_name
                    items.append(
                        Action(name=name,
                               action="editor._menu_new_node('%s',%s)" %
                               (class_name, prompt)))
        return items
github NMGRL / pychron / pychron / canvas / canvas2D / extraction_line_canvas2D.py View on Github external
from pychron.canvas.canvas2D.overlays.extraction_line_overlay import ExtractionLineInfoTool, ExtractionLineInfoOverlay
from pychron.canvas.canvas2D.scene.extraction_line_scene import ExtractionLineScene
from pychron.canvas.canvas2D.scene.primitives.connections import Elbow
from pychron.canvas.canvas2D.scene.primitives.lasers import Laser
from pychron.canvas.canvas2D.scene.primitives.primitives import BorderLine
from pychron.canvas.canvas2D.scene.primitives.valves import RoughValve, \
    BaseValve, Switch, ManualSwitch
from pychron.canvas.scene_viewer import SceneCanvas
from pychron.globals import globalv

W = 2
H = 2


class ExtractionLineAction(Action):
    chamber = Str


class ExtractionLineCanvas2D(SceneCanvas):
    """
    """
    scene_klass = ExtractionLineScene

    use_backbuffer = True
    border_visible = False
    active_item = Any

    selected_id = Str
    show_axes = False
    show_grids = False
    use_zoom = False
github NMGRL / pychron / pychron / graph / tools / analysis_inspector.py View on Github external
def contextual_menu_contents(self):
        """
        """
        actions = (Action(name='Recall',
                          on_perform=self._recall_analysis),
                   Action(name='Set tag',
                          on_perform=self._set_tag),
                   Action(name='Set Omit',
                          on_perform=self._set_omit),
                   Action(name='Set Invalid',
                          on_perform=self._set_invalid))
        return actions
github NMGRL / pychron / pychron / pipeline / tasks / panes.py View on Github external
def save_menu_factory():
            return MenuManager(Action(name='Save PDF Figure',
                                      action='add_pdf_figure'),
                               Action(name='Save Iso Evo',
                                      action='add_iso_evo_persist'),
                               Action(name='Save Blanks',
                                      action='add_blanks_persist'),
                               Action(name='Save ICFactor',
                                      action='add_icfactor_persist'),
                               name='Save')
github NMGRL / pychron / pychron / classifier / tasks / actions.py View on Github external
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================
from __future__ import absolute_import
from __future__ import print_function
from traitsui.menu import Action

from pychron.classifier.isotope_trainer import IsotopeTrainer


class TrainIsotopeClassifierAction(Action):
    name = 'Train'

    def perform(self, event):
        app = event.task.application
        dvc = app.get_service('pychron.dvc.dvc.DVC')
        print('asdfasd', dvc)
        trainer = IsotopeTrainer(dvc=dvc)
        trainer.train()
        # trainer.edit_traits(view=View('test'))
github NMGRL / pychron / pychron / extraction_line / programmer / valve_programmer.py View on Github external
def traits_view(self):
        v = View(UItem('canvas', editor=ComponentEditor()),
                 resizable=True,
                 toolbar=ToolBar(Action(name='Save State',
                                        action='save_state'),
                                 Action(name='Assemble',
                                        action='assemble'),
                 ),
                 width=500)
        return v
github NMGRL / pychron / pychron / pipeline / tasks / panes.py View on Github external
def chain_menu_factory():
            return MenuManager(Action(name='Chain Ideogram',
                                      action='chain_ideogram'),
                               Action(name='Chain Isotope Evolution',
                                      action='chain_isotope_evolution'),
                               Action(name='Chain Spectrum',
                                      action='chain_spectrum'),
                               Action(name='Chain Blanks',
                                      action='chain_blanks'),
                               Action(name='Chain ICFactors',
                                      action='chain_icfactors'),
                               name='Chain')
github NMGRL / pychron / pychron / graph / context_menu_mixin.py View on Github external
def action_factory(self, name, func, **kw):
        """
        """
        a = Action(name=name, on_perform=getattr(self, func),
                   #                   visible_when='0',
                   **kw)

        return a
github LTS5 / connectomeviewer / cviewer / plugins / cff2 / ui / ctrack_tree_node.py View on Github external
###
    # Private Traits
    
    # activate / deactivate logic
    # if the node is activated, this means that there exists a
    # corresponding RenderManager instance
    
    _TracksRender = Instance(Action,
                               kw={'name': 'Show Tracks (fos)', 
                                   'action': 'object.render_tracks',
                                    'tooltip':'Show the rendered tracks',
                                    'enabled_when':'object.loaded == True'
                                    }, )
    
    _TrackVisLaunchAction = Instance(Action,
                               kw={'name': 'Launch TrackVis', 
                                   'action': 'object.launch_trackvis',
                                    'tooltip':'Launch TrackVis',
                                    'enabled_when':'object.loaded == True'}, )
    
    # the menu shown after right-click
    menu = Instance(Menu, transient=True)
    
    def get_children(self, object):
        """ Get the object's children. """
        pass
        
    ######################################################################
    # Non-public interface
    ######################################################################