How to use enaml - 10 common examples

To help you get started, we’ve selected a few enaml 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 MatthieuDartiailh / HQCMeas / tests / tasks / manager / test_plugin.py View on Github external
def test_views_request(self):
        self.workbench.register(TaskManagerManifest())
        core = self.workbench.get_plugin(u'enaml.workbench.core')
        com = u'hqc_meas.task_manager.views_request'
        with enaml.imports():
            from hqc_meas.tasks.views.base_task_views import ComplexView
        views, miss = core.invoke_command(com,
                                          {'task_classes': ['ComplexTask']},
                                          self)
        assert_in('ComplexTask', views)
        assert_equal(views['ComplexTask'], ComplexView)
        assert_equal(miss, [])
github MatthieuDartiailh / HQCMeas / tests / debug / test_workspace.py View on Github external
# -*- coding: utf-8 -*-
#==============================================================================
# module : test_workspace.py
# author : Matthieu Dartiailh
# license : MIT license
#==============================================================================
import enaml
from enaml.workbench.api import Workbench
import os
import logging
from configobj import ConfigObj
from nose.tools import (assert_in, assert_not_in, assert_equal, assert_true,
                        assert_is_instance, assert_false)

from hqc_meas.debug.debugger_workspace import LOG_ID
with enaml.imports():
    from enaml.workbench.core.core_manifest import CoreManifest
    from enaml.workbench.ui.ui_manifest import UIManifest
    from hqc_meas.utils.state.manifest import StateManifest
    from hqc_meas.utils.preferences.manifest import PreferencesManifest
    from hqc_meas.utils.log.manifest import LogManifest
    from hqc_meas.tasks.manager.manifest import TaskManagerManifest
    from hqc_meas.instruments.manager.manifest import InstrManagerManifest
    from hqc_meas.debug.debugger_manifest import DebuggerManifest
    from hqc_meas.app_manifest import HqcAppManifest

    from .helpers import (TestSuiteManifest, TestDebugger, TestDebuggerView,
                          tester)

from ..util import (complete_line, process_app_events, close_all_windows,
                    remove_tree, create_test_dir)
github nucleic / enaml / tests / test_color.py View on Github external
def test_color_initialization():
    """Test the different initialization format supported by Color.

    """
    components = [1, 2, 3, 4]
    c = Color(*components)
    for name, value in zip(['red', 'green', 'blue', 'alpha'], components):
        assert getattr(c, name) == value

    c = Color(alpha=-1)
    for name in ['red', 'green', 'blue', 'alpha']:
        assert getattr(c, name) == 0

    assert c._tkdata is None

    try:
        from enaml.qt.q_resource_helpers import get_cached_qcolor
    except Exception:
        return
    get_cached_qcolor(c)
    assert c._tkdata is not None
github MatthieuDartiailh / HQCMeas / tests / __init__.py View on Github external
def setup_package():
    sys.path.append('..')
    QtApplication()
    print('')
    print(complete_line(__name__ + '__init__.py : setup_package()', '='))
    directory = os.path.dirname(__file__)
    util_path = os.path.join(directory, '..', 'hqc_meas', 'utils',
                             'preferences')
    def_path = os.path.join(util_path, 'default.ini')
    if os.path.isfile(def_path):
        os.rename(def_path, os.path.join(util_path, '_user_default.ini'))
github MatthieuDartiailh / HQCMeas / tests / utils / log / test_plugin.py View on Github external
def test_formatter(self):
        """ Test setting the formatter of a handler.

        """
        if not QtApplication.instance():
            QtApplication()

        core = self.workbench.get_plugin(u'enaml.workbench.core')
        model = PanelModel()
        handler = GuiHandler(model=model)
        core.invoke_command(u'hqc_meas.logging.add_handler',
                            {'id': 'ui', 'handler': handler, 'logger': 'test'},
                            self)

        formatter = logging.Formatter('toto : %(message)s')
        core.invoke_command(u'hqc_meas.logging.set_formatter',
                            {'formatter': formatter, 'handler_id': 'ui'},
                            self)

        logger = logging.getLogger('test')
        logger.info('test')
github nucleic / enaml / enaml / testing / fixtures.py View on Github external
def qt_app():
    """Make sure a QtApplication is active.

    """
    try:
        from enaml.qt.qt_application import QtApplication
    except ImportError:
        pytest.skip('No Qt binding found: %s' % format_exc())

    app = QtApplication.instance()
    if app is None:
        app = QtApplication()
        yield app
        app.stop()
    else:
        yield app
github MatthieuDartiailh / HQCMeas / tests / tasks / logic_tasks / test_loop_task.py View on Github external
def test_view2(self):
        # Intantiate a view with a selected interface.
        interface = LinspaceLoopInterface()
        self.task.interface = interface

        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        LoopView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_is(self.task.interface, interface)
github MatthieuDartiailh / HQCMeas / tests / util.py View on Github external
def close_all_windows():
    qapp = QtApplication.instance()._qapp
    qapp.flush()
    qapp.processEvents()
    sleep(0.1)
    for window in Window.windows:
        window.close()
    qapp.flush()
    qapp.processEvents()
github nucleic / enaml / tests / utils.py View on Github external
def get_window(qtbot, cls=Window, timeout=1000):
    """Convenience function running the event loop and returning the first
    window found in the set of active windows.

    Parameters
    ----------
    cls : type, optional
        Type of the window which should be returned.

    timeout : int, optional
        Timeout after which the operation should fail in ms

    Returns
    -------
    window : Window or None
        Return the first window found matching the specified class
github MatthieuDartiailh / HQCMeas / tests / tasks / instr_tasks / test_pna_tasks.py View on Github external
def test_view1(self):
        # Intantiate a view with no selected interface and select one after
        window = enaml.widgets.api.Window()
        core = self.workbench.get_plugin('enaml.workbench.core')
        view = RFFrequencyView(window, task=self.task, core=core)
        window.show()

        process_app_events()

        assert_in('AgilentPNA', view.drivers)
        self.task.selected_driver = 'AgilentPNA'
        process_app_events()
        assert_is_instance(self.task.interface, PNASetRFFrequencyInterface)