예제 #1
0
 def view_application_event_loop(self, kind):
     with self.event_loop_until_condition(lambda: self.closed):
         self.gui.invoke_later(
             toolkit().view_application,
             context=self.model,
             view=simple_view,
             kind=kind,
             handler=self.handler,
         )
         self.gui.invoke_after(100, self.close_dialog)
예제 #2
0
    def do (self, event, controllers=[], *args, **kw):
        """ Processes a keyboard event.
        """
        if isinstance(controllers, dict):
            controllers = controllers.values()
        elif not isinstance(controllers, SequenceTypes):
            controllers = [ controllers ]
        else:
            controllers = list(controllers)

        return self._do(toolkit().key_event_to_name(event),
                         controllers, args, kw.get('recursive', False))
예제 #3
0
def get_plugin_classes():
    """Get list of default plugin classes to use for Mayavi."""

    # Force the selection of a toolkit:
    from traitsui.api import toolkit
    toolkit()
    from traits.etsconfig.api import ETSConfig
    try_use_ipython = preference_manager.root.use_ipython
    use_ipython = False
    if ETSConfig.toolkit == 'wx' and try_use_ipython:
        try:
            # If the right versions of IPython, EnvisagePlugins and
            # Pyface are not installed, this import will fail.
            from envisage.plugins.ipython_shell.view.ipython_shell_view \
                    import IPythonShellView
            use_ipython = True
        except:
            pass

    if use_ipython:
        from envisage.plugins.ipython_shell.ipython_shell_plugin import \
                IPythonShellPlugin
        PythonShellPlugin = IPythonShellPlugin
    else:
        from envisage.plugins.python_shell.python_shell_plugin import PythonShellPlugin
    from envisage.plugins.text_editor.text_editor_plugin import TextEditorPlugin
    from apptools.logger.plugin.logger_plugin import LoggerPlugin
    from tvtk.plugins.scene.ui.scene_ui_plugin import SceneUIPlugin
    from mayavi.plugins.mayavi_ui_plugin import MayaviUIPlugin
    plugins = get_non_gui_plugin_classes()
    plugins.extend([
        LoggerPlugin,
        MayaviUIPlugin,
        SceneUIPlugin,
        PythonShellPlugin,
        TextEditorPlugin,
    ])
    return plugins
예제 #4
0
파일: app.py 프로젝트: PerryZh/mayavi
def get_plugin_classes():
    """Get list of default plugin classes to use for Mayavi."""

    # Force the selection of a toolkit:
    from traitsui.api import toolkit
    toolkit()
    from traits.etsconfig.api import ETSConfig
    try_use_ipython = preference_manager.root.use_ipython
    use_ipython = False
    if ETSConfig.toolkit == 'wx' and try_use_ipython:
        try:
            # If the right versions of IPython, EnvisagePlugins and
            # Pyface are not installed, this import will fail.
            from envisage.plugins.ipython_shell.view.ipython_shell_view \
                    import IPythonShellView
            use_ipython = True
        except: pass

    if use_ipython:
        from envisage.plugins.ipython_shell.ipython_shell_plugin import \
                IPythonShellPlugin
        PythonShellPlugin = IPythonShellPlugin
    else:
        from envisage.plugins.python_shell.python_shell_plugin import PythonShellPlugin
    from envisage.plugins.text_editor.text_editor_plugin import TextEditorPlugin
    from apptools.logger.plugin.logger_plugin import LoggerPlugin
    from tvtk.plugins.scene.ui.scene_ui_plugin import SceneUIPlugin
    from mayavi.plugins.mayavi_ui_plugin import MayaviUIPlugin
    plugins = get_non_gui_plugin_classes()
    plugins.extend([
                LoggerPlugin,
                MayaviUIPlugin,
                SceneUIPlugin,
                PythonShellPlugin,
                TextEditorPlugin,
                ])
    return plugins
예제 #5
0
    def view_application(self, kind, button=None):
        if button is None:
            self.gui.invoke_later(self.close_dialog)
        else:
            self.gui.invoke_later(self.click_button, text=button)

        timer = CallbackTimer.single_shot(callback=self.stop_event_loop,
                                          interval=1.0)
        try:
            self.result = toolkit().view_application(
                context=self.model,
                view=simple_view,
                kind=kind,
                handler=self.handler,
            )
        finally:
            timer.stop()
예제 #6
0
from traits.api import Trait, TraitError, TraitHandler, TraitFactory

logger = logging.getLogger(__name__)

try:
    from traitsui.api import toolkit
except ImportError:
    toolkit = None
    logger.exception("Could not import TraitsUI, KivaFontTrait has no editor")


KivaFontEditor = None

if toolkit is not None:
    if toolkit().toolkit == "wx":
        from .ui.wx.kiva_font_editor import KivaFontEditor
    elif toolkit().toolkit.startswith("qt"):
        # FIXME
        # from .ui.qt4.kiva_font_editor import KivaFontEditor
        pass


# -----------------------------------------------------------------------------
#  Convert a string into a valid 'Font' object (if possible):
# -----------------------------------------------------------------------------

# Strings to ignore in text representations of fonts
font_noise = ["pt", "point", "family"]

font_families = font_styles = font_weights = DEFAULT = NORMAL = WEIGHT_NORMAL = None