Beispiel #1
0
    def create_editor(self):

        if self._names:
            choice_list = [InstanceFactoryChoice(name=n, klass=k)
                           for n, k in zip(self._names, self._klasses)]
        else:
            choice_list = [InstanceFactoryChoice(klass=k)
                           for k in self._klasses]

        return InstanceEditor(values=choice_list, kind='live')
Beispiel #2
0
class Team(HasStrictTraits):

    #-------------------------------------------------------------------------
    #  Trait definitions:
    #-------------------------------------------------------------------------

    name = Str
    captain = Instance(Person)
    roster = List(Person)

    #-------------------------------------------------------------------------
    #  Traits view definitions:
    #-------------------------------------------------------------------------

    traits_view = View([[
        'name', '_', Item(
            'captain@',
            editor=InstanceEditor(
                name='roster',
                editable=False,
                values=[
                    InstanceFactoryChoice(
                        klass=Person, name='Non player', view='edit_view')
                ])), '_'
    ], ['captain@', '|<>']])
Beispiel #3
0
class Team(HasStrictTraits):

    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------

    name = Str
    captain = Instance(Person)
    roster = List(Person)

    #---------------------------------------------------------------------------
    #  Traits view definitions:
    #---------------------------------------------------------------------------

    traits_view = View([
        'name', '_',
        Item('captain',
             editor=InstanceEditor(name='roster',
                                   label='Edit...',
                                   values=[
                                       InstanceFactoryChoice(klass=Person,
                                                             name='Non player',
                                                             view='edit_view')
                                   ]))
    ],
                       buttons=['OK', 'Cancel'])
class Team(HasStrictTraits):

    #-------------------------------------------------------------------------
    #  Trait definitions:
    #-------------------------------------------------------------------------

    name = Str
    captain = Instance(Person)
    roster = List(Instance(Person))

    #-------------------------------------------------------------------------
    #  Traits view definitions:
    #-------------------------------------------------------------------------

    traits_view = View(
        'name', '_', Item(
            'captain@', editor=InstanceEditor(
                name='roster', values=[
                    InstanceFactoryChoice(
                        klass=Person, name='Non player')])))
        for input in interactor.desired_inputs:
            if isinstance(inputs[input], Distribution):
                interactor.results_context['_seeds'][input] = []
                for result in results:
                    interactor.results_context['_seeds'][input].append(
                        result['_seeds'][input])

        self._updated = True


#-------------------------------------------------------------------------------
#  'StochasticInteractor' class:
#-------------------------------------------------------------------------------

distribution_classes = [
    InstanceFactoryChoice(klass=Constant, name='Constant', view='view'),
    InstanceFactoryChoice(klass=Gaussian, name='Gaussian', view='view'),
    InstanceFactoryChoice(klass=Triangular, name='Triangular', view='view'),
    InstanceFactoryChoice(klass=Uniform, name='Uniform', view='view'),
]


class StochasticInteractor(Interactor):

    results_context = Any({})

    desired_inputs = Any({})
    desired_outputs = Any([])

    realizations_per_host = Int(10)