Exemple #1
0
 def _actions_default(self):
     return [
         Group(
             Action(
                 image=ImageResource(
                     '16x16/x-axis',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="View along the -X axis",
                 on_perform=self.x_minus_view,
             ),
             Action(
                 image=ImageResource(
                     '16x16/x-axis',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="View along the +X axis",
                 on_perform=self.x_plus_view,
             ),
             Action(
                 image=ImageResource(
                     '16x16/y-axis',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="View along the -Y axis",
                 on_perform=self.y_minus_view,
             ),
             Action(
                 image=ImageResource(
                     '16x16/y-axis',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="View along the +Y axis",
                 on_perform=self.y_plus_view,
             ),
             Action(
                 image=ImageResource(
                     '16x16/z-axis',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="View along the -Z axis",
                 on_perform=self.z_minus_view,
             ),
             Action(
                 image=ImageResource(
                     '16x16/z-axis',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="View along the +Z axis",
                 on_perform=self.z_plus_view,
             ),
             Action(
                 image=ImageResource(
                     '16x16/isometric',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="Obtain an isometric view",
                 on_perform=self.isometric_view,
             ),
         ),
         Group(
             Action(
                 image=ImageResource(
                     '16x16/parallel',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip='Toggle parallel projection',
                 style="toggle",
                 on_perform=self._toggle_projection,
                 checked=self.parallel_projection,
             ),
             Action(
                 image=ImageResource(
                     '16x16/origin_glyph',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip='Toggle axes indicator',
                 style="toggle",
                 enabled=(self.marker is not None),
                 on_perform=self._toggle_axes,
                 checked=self.show_axes,
             ),
             Action(
                 image=ImageResource(
                     '16x16/fullscreen',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip=
                 'Full Screen (press "q" or "e" or Esc to exit fullscreen)',
                 style="push",
                 on_perform=self._full_screen_fired,
             ),
         ),
         Group(
             Action(
                 image=ImageResource(
                     '16x16/save',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip="Save a snapshot of this scene",
                 on_perform=self._save_snapshot,
             ),
             Action(
                 image=ImageResource(
                     '16x16/configure',
                     search_path=[self._get_image_path()],
                 ),
                 tooltip='Configure the scene',
                 style="push",
                 on_perform=self._configure_scene,
             ),
         ),
     ]
    def _create_group(self, group_definition):
        """ Create a group implementation from a definition. """

        return Group(id=group_definition.id)
Exemple #3
0
#
# Thanks for using Enthought open source!
""" Menu Manager example. """

import os, sys

# Put the Enthought library on the Python path.
sys.path.append(os.path.abspath(r"..\..\.."))

from pyface.action.api import Action
from pyface.action.api import Group, MenuManager, Separator

file_menu = MenuManager(
    Group(
        Action(name="New Project..."),
        Action(name="Open Project..."),
        id="OpenGroup",
    ),
    Group(
        Action(name="Close Project"),
        Action(name="Close Active Editor"),
        id="CloseGroup",
    ),
    Group(
        Action(name="Export to HTML..."),
        Action(name="Print..."),
        id="ExportGroup",
    ),
    Group(Action(name="Exit"), id="ExitGroup"),
)
file_menu.dump()
    def get_context_menu(self, pos):
        """ Returns a context menu containing split/collapse actions

        pos : position (in global coordinates) where the context menu was
        requested
        """
        menu = MenuManager()
        splitter = None

        splitter = None
        for tabwidget in self.tabwidgets():
            # obtain tabwidget's bounding rectangle in global coordinates
            global_rect = QtCore.QRect(
                tabwidget.mapToGlobal(QtCore.QPoint(0, 0)), tabwidget.size())
            if global_rect.contains(pos):
                splitter = tabwidget.parent()

        # no split/collapse context menu for positions outside any tabwidget
        # region
        if not splitter:
            return

        # add split actions (only show for non-empty tabwidgets)
        if not splitter.is_empty():
            actions = [
                Action(id='split_hor',
                       name='Create new pane to the right',
                       on_perform=lambda: splitter.split(orientation=QtCore.Qt.
                                                         Horizontal)),
                Action(id='split_ver',
                       name='Create new pane to the bottom',
                       on_perform=lambda: splitter.split(orientation=QtCore.Qt.
                                                         Vertical))
            ]

            splitgroup = Group(*actions, id='split')
            menu.append(splitgroup)

        # add collapse action (only show for collapsible splitters)
        if splitter.is_collapsible():
            if splitter is splitter.parent().leftchild:
                if splitter.parent().orientation() == QtCore.Qt.Horizontal:
                    text = 'Merge with right pane'
                else:
                    text = 'Merge with bottom pane'
            else:
                if splitter.parent().orientation() == QtCore.Qt.Horizontal:
                    text = 'Merge with left pane'
                else:
                    text = 'Merge with top pane'
            actions = [
                Action(id='merge',
                       name=text,
                       on_perform=lambda: splitter.collapse())
            ]

            collapsegroup = Group(*actions, id='collapse')
            menu.append(collapsegroup)

        # return QMenu object
        return menu
Exemple #5
0
 def get_actions_Menu_Edit_PrefGroup(self):
     return [
         Group(PreferencesAction(), absolute_position="last"),
     ]
Exemple #6
0
 def get_groups(self, location, menu_name, *group_names):
     actions = []
     for group_name in group_names:
         actions.extend(
             self.get_actions_wrapper(location, menu_name, group_name))
     return Group(*actions, id=menu_name)
Exemple #7
0
 def get_group(self, location, menu_name, group_name):
     actions = self.get_actions_wrapper(location, menu_name, group_name)
     return Group(*actions, id=group_name)