How to use the traits.api.DelegatesTo function in traits

To help you get started, we’ve selected a few traits 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 mne-tools / mne-python / mne / gui / _fiducials_gui.py View on Github external
Left peri-auricular point coordinates.
    nasion : array (1, 3)
        Nasion coordinates.
    rpa : array (1, 3)
        Right peri-auricular point coordinates.
    """

    subject_source = Instance(MRISubjectSource, ())
    bem_low_res = Instance(SurfaceSource, ())
    bem_high_res = Instance(SurfaceSource, ())
    fid = Instance(FiducialsSource, ())

    fid_file = DelegatesTo('fid', 'file')
    fid_fname = DelegatesTo('fid', 'fname')
    fid_points = DelegatesTo('fid', 'points')
    subjects_dir = DelegatesTo('subject_source')
    subject = DelegatesTo('subject_source')
    subject_has_bem = DelegatesTo('subject_source')
    lpa = Array(float, (1, 3))
    nasion = Array(float, (1, 3))
    rpa = Array(float, (1, 3))

    reset = Event(desc="Reset fiducials to the file.")

    # info
    can_save = Property(depends_on=['file', 'can_save_as'])
    can_save_as = Property(depends_on=['lpa', 'nasion', 'rpa'])
    can_reset = Property(depends_on=['file', 'fid.points', 'lpa', 'nasion',
                                     'rpa'])
    fid_ok = Property(depends_on=['lpa', 'nasion', 'rpa'], desc="All points "
                      "are set")
    default_fid_fname = Property(depends_on=['subjects_dir', 'subject'],
github NMGRL / pychron / pychron / envisage / browser / analysis_table.py View on Github external
oanalyses = List
    selected = Any
    dclicked = Any

    context_menu_event = Event

    analysis_filter = CStr
    analysis_filter_values = List
    analysis_filter_comparator = Enum('=', '<', '>', '>=', '<=', 'not =', 'startswith')
    analysis_filter_parameter = Str
    analysis_filter_parameters = Property(List, depends_on='tabular_adapter.columns')

    # omit_invalid = Bool(True)
    table_configurer = Instance(AnalysisTableConfigurer)

    limit = DelegatesTo('table_configurer')
    omit_invalid = DelegatesTo('table_configurer')

    no_update = False
    scroll_to_row = Event
    scroll_to_bottom = Event
    scroll_to_top = Event

    refresh_needed = Event
    tabular_adapter = Instance(AnalysisAdapter)
    append_replace_enabled = Bool(True)

    add_analysis_set_button = Button
    refresh_analysis_set_button = Button

    analysis_set = Str
    analysis_set_names = List
github enthought / mayavi / mayavi / modules / outline.py View on Github external
# Enum to set the outline type.
    outline_mode = Enum('full', 'cornered',
                        desc='if outline mode is "full" or "cornered"')

    actor = Instance(Actor, allow_none=False, record=True)

    input_info = PipelineInfo(datasets=['any'],
                              attribute_types=['any'],
                              attributes=['any'])

    # An outline source, optionally used to choose the bounds of the
    # outline.
    outline_source = Instance(tvtk.OutlineSource, ())

    bounds = DelegatesTo('outline_source',
                desc="the bounds of the outline: xmin, xmax, ymin, ymax")

    manual_bounds = Bool(
                desc="whether the bounds are automatically inferred from "
                     "the data source")

    # Create the UI for the traits.

    # The controls for the outline_filter should be enabled only when the
    # Cornered Outline Filter is selected.
    view = View(Group(
                    Group(
                        Item(name='outline_mode'),
                        Item(name='outline_filter',
                                style='custom',
                                enabled_when='outline_mode == "cornered"',
github mne-tools / mne-python / mne / gui / _coreg_gui.py View on Github external
"""Coregistration panel for Head<->MRI with scaling."""

    model = Instance(CoregModel)

    # parameters
    reset_params = Button(label=_RESET_LABEL)
    n_scale_params = DelegatesTo('model')
    parameters = DelegatesTo('model')
    scale_step = Float(1.)
    scale_x = DelegatesTo('model')
    scale_x_dec = Button('-')
    scale_x_inc = Button('+')
    scale_y = DelegatesTo('model')
    scale_y_dec = Button('-')
    scale_y_inc = Button('+')
    scale_z = DelegatesTo('model')
    scale_z_dec = Button('-')
    scale_z_inc = Button('+')
    rot_step = Float(1.)
    rot_x = DelegatesTo('model')
    rot_x_dec = Button('-')
    rot_x_inc = Button('+')
    rot_y = DelegatesTo('model')
    rot_y_dec = Button('-')
    rot_y_inc = Button('+')
    rot_z = DelegatesTo('model')
    rot_z_dec = Button('-')
    rot_z_inc = Button('+')
    trans_step = Float(1.)
    trans_x = DelegatesTo('model')
    trans_x_dec = Button('-')
    trans_x_inc = Button('+')
github NMGRL / pychron / pychron / spectrometer / jobs / magnet_scan.py View on Github external
def psuedo_peak(center, start, stop, step, magnitude=500, peak_width=0.008):
    x = linspace(start, stop, step)
    gaussian = lambda x: magnitude * exp(-((center - x) / peak_width) ** 2)

    for i, d in enumerate(gaussian(x)):
        if abs(center - x[i]) < peak_width:
        #            d = magnitude
            d = magnitude + magnitude / 50.0 * random.random()
        yield d


class MagnetScan(SpectrometerTask):
#    graph = Any
    detectors = DelegatesTo('spectrometer')
    integration_time=DelegatesTo('spectrometer')

    reference_detector = Any
    additional_detectors = List

    start_mass = Float(36)
    stop_mass = Float(40)
    step_mass = Float(1)
    normalize = Bool(True)

    verbose = False

    def _scan_dac(self, values):

        if self.spectrometer.simulation:
            self._peak_generator = psuedo_peak(values[len(values) / 2] + 0.001, values[0], values[-1], len(values))
github mne-tools / mne-python / mne / gui / _coreg_gui.py View on Github external
lpa_weight = DelegatesTo('model')
    nasion_weight = DelegatesTo('model')
    rpa_weight = DelegatesTo('model')
    hsp_weight = DelegatesTo('model')
    eeg_weight = DelegatesTo('model')
    hpi_weight = DelegatesTo('model')
    has_lpa_data = DelegatesTo('model')
    has_nasion_data = DelegatesTo('model')
    has_rpa_data = DelegatesTo('model')
    has_hsp_data = DelegatesTo('model')
    has_eeg_data = DelegatesTo('model')
    has_hpi_data = DelegatesTo('model')
    icp_iterations = DelegatesTo('model')
    icp_start_time = DelegatesTo('model')
    icp_angle = DelegatesTo('model')
    icp_distance = DelegatesTo('model')
    icp_scale = DelegatesTo('model')
    icp_fid_match = DelegatesTo('model')
    n_scale_params = DelegatesTo('model')

    view = View(VGroup(
        VGrid(HGroup(Item('icp_iterations', label='Iterations',
                          width=_MM_WIDTH, tooltip='Maximum ICP iterations to '
                          'perform (per click)'),
                     Spring(), show_labels=True), label='ICP iterations (max)',
              show_border=_SHOW_BORDER),
        VGrid(Item('icp_angle', label=u'Angle (°)', width=_MM_WIDTH,
                   tooltip='Angle convergence threshold'),
              Item('icp_distance', label='Distance (mm)', width=_MM_WIDTH,
                   tooltip='Distance convergence threshold'),
              Item('icp_scale', label='Scale (%)',
                   tooltip='Scaling convergence threshold', width=_MM_WIDTH,
github NMGRL / pychron / pychron / experiment / factory.py View on Github external
clear_button = Button('Clear')
    save_button = Button('Save')
    edit_mode_button = Button('Edit')
    edit_enabled = DelegatesTo('run_factory')

    auto_increment_id = Bool(False)
    auto_increment_position = Bool(False)

    queue = Instance(ExperimentQueue, ())

    ok_add = Property(depends_on='mass_spectrometer, extract_device, labnumber, username, load_name')

    labnumber = DelegatesTo('run_factory')
    load_name = DelegatesTo('queue_factory')
    username = DelegatesTo('queue_factory')
    mass_spectrometer = DelegatesTo('queue_factory')
    extract_device = DelegatesTo('queue_factory')

    selected_positions = List
    default_mass_spectrometer = Str

    _load_persistence_flag = False
    # ===========================================================================
    # permisions
    # ===========================================================================
    # max_allowable_runs = Int(10000)
    # can_edit_scripts = Bool(True)

    # def __init__(self, *args, **kw):
    #     super(ExperimentFactory, self).__init__(auto_setup=False, *args, **kw)

    def activate(self, load_persistence=True):
github enthought / jigna / jigna / core / concurrent.py View on Github external
# Progress information.
    progress = Property(depends_on='promise._progress')

    # Optional information.
    info = Str('')

    #################################
    # Private Traits.

    # The thread in which the function is running.
    _thread = Instance(Thread)

    # The Deferred object for the operation and its promise.
    _deferred = Instance(Deferred)
    promise = DelegatesTo('_deferred', 'promise')

    ############################################################################
    # `object` interface.
    ############################################################################
    def __init__(self, func, f_on_status=None, f_on_progress=None,
                 future_kw=None, dispatch='same', args=None, kw=None):
        """Constructor for a Future.

        If an exception is raised when the future runs, ``sys.exc_info()``
        is stored in the error trait and the ``status`` is set to "error"

        Parameters
        ----------

        func : callable
            The callable to execute in another thread.
github mne-tools / mne-python / mne / gui / _coreg_gui.py View on Github external
raw_src = DelegatesTo('model', 'hsp')
    # Set internally
    subject_panel = Instance(SubjectSelectorPanel)
    fid_panel = Instance(FiducialsPanel)
    headview = Instance(HeadViewController)
    view_options_panel = Instance(ViewOptionsPanel)
    hsp_always_visible = Bool(False, label="Always Show Head Shape")
    view_options = Button(label="Display options...")

    # Omit Points
    distance = Float(10., desc="maximal distance for head shape points from "
                     "the surface (mm)")
    omit_points = Button(label='Omit', desc="to omit head shape points "
                         "for the purpose of the automatic coregistration "
                         "procedure (mm).")
    grow_hair = DelegatesTo('model')
    reset_omit_points = Button(label=_RESET_LABEL, desc="to reset the "
                               "omission of head shape points to include all.")
    omitted_info = Str('No points omitted')

    def _subject_panel_default(self):
        return SubjectSelectorPanel(model=self.model.mri.subject_source)

    def _fid_panel_default(self):
        return FiducialsPanel(model=self.model.mri, headview=self.headview)

    def _headview_default(self):
        return HeadViewController(system='RAS', scene=self.scene)

    def _omit_points_fired(self):
        distance = self.distance / 1000.
        self.model.omit_hsp_points(distance)
github ptomato / Beams / beams / MainWindow.py View on Github external
MAX_QUEUE_SIZE = 0  # i.e. infinite


class MainWindow(HasTraits):
    '''The main window for the Beams application.'''

    # Current folder for file dialog
    _current_folder = None

    camera = Instance(Camera)
    id_string = DelegatesTo('camera')
    resolution = DelegatesTo('camera')
    status = Str()
    screen = Instance(CameraImage, args=())
    cmap = DelegatesTo('screen')
    display_frame_rate = Range(1, 60, 15)
    transform_plugins = List(Instance(TransformPlugin))
    display_plugins = List(Instance(DisplayPlugin))
    acquisition_thread = Instance(AcquisitionThread)  # default: None
    processing_thread = Instance(ProcessingThread)  # default: None
    processing_queue = Instance(queue.Queue, kw={'maxsize': MAX_QUEUE_SIZE})
    cameras_dialog = Instance(CameraDialog, args=())

    # Actions
    about = Action(
        name='&About...',
        tooltip='About Beams',
        image=find_icon('about'),
        action='action_about')
    save = Action(
        name='&Save Image',