Example #1
0
class LoggerPreferences(PreferencesHelper):
    """ The persistent service exposing the Logger plugin's API.
    """

    #### Preferences ###########################################################

    # The log levels
    level = Trait(
        'Info',
        {
            'Debug': logging.DEBUG,
            'Info': logging.INFO,
            'Warning': logging.WARNING,
            'Error': logging.ERROR,
            'Critical': logging.CRITICAL,
        },
        is_str=True,
    )

    enable_agent = Bool(False)
    smtp_server = Str()
    to_address = Str()
    from_address = Str()

    # The path to the preferences node that contains the preferences.
    preferences_path = Str('enthought.logger')
Example #2
0
class SaveSceneToImage(SceneAction):
    """ An action that saves a scene to an image. """

    #### 'Action' interface ###################################################

    # Name of the action.
    name = 'Image'

    #### 'SaveSceneToImage' interface #########################################

    # The save method name.
    save_method = Str('save')

    # The wildcard for the file dialog.
    wildcard = Str("All files (*.*)|*.*")

    ###########################################################################
    # 'Action' interface.
    ###########################################################################

    def perform(self, event):
        """ Perform the action. """

        dialog = FileDialog(parent=self.window.control,
                            title='Save scene to %s' % self.name,
                            action='save as',
                            wildcard=self.wildcard)
        if dialog.open() == OK:
            scene = self.scene_manager.current_scene
            if scene is not None:
                method = getattr(scene, self.save_method)
                method(dialog.path)

        return
class Str(Variable):
    """A variable wrapper for a string variable.
       """
    
    def __init__(self, default_value='', iotype=None, desc=None, 
                 **metadata):

        # Put iotype in the metadata dictionary
        if iotype is not None:
            metadata['iotype'] = iotype
            
        # Put desc in the metadata dictionary
        if desc is not None:
            metadata['desc'] = desc

        self._validator = Enthought_Str(default_value=default_value, **metadata)
            
        super(Str, self).__init__(default_value=default_value, **metadata)

    def validate(self, obj, name, value):
        """ Use the Enthought trait's validate.
        """
        return self._validator.validate(obj, name, value)

    def create_editor(self):
        """ User the one in the Enthought trait.
        """
        return self._validator.create_editor()
Example #4
0
class CSVDecoder(DataDecoder):
  """
      Decodes lines of CSV formatted text.
  """
  name = Str('CSV Decoder')
  view = View(
    Item(name = 'separator', label='Field separator'),
    Item(name = 'variable_names', label='Field names'),
    Item(label= "(use '_' to ignore a field)"),
    title='CSV decoder'
  )
  separator = Str(',')
  variable_names = Str('_,a,b,c,d')
  
  def decode(self, data):
    """
        Decode CSV input data then assign variables based on a CSV format list
        list of names, using an '_' to ignore a field.
    """
    data_list = data.split(self.separator)
    var_names = self.variable_names.split(',')
    
    if len(data_list) >= len(var_names):
      data_dict = {}
      for n, var in enumerate(var_names):
        if var != '_':
          try:
            data_dict[var] = float(data_list[n])
          except:
            pass
      return data_dict
      
    return None
    
Example #5
0
class Str(Variable):
    """A variable wrapper for a string variable.
       """
    def __init__(self, default_value='', iotype=None, desc=None, **metadata):

        # Put iotype in the metadata dictionary
        if iotype is not None:
            metadata['iotype'] = iotype

        # Put desc in the metadata dictionary
        if desc is not None:
            metadata['desc'] = desc

        self._validator = Enthought_Str(default_value=default_value,
                                        **metadata)

        super(Str, self).__init__(default_value=default_value, **metadata)

    def validate(self, obj, name, value):
        """ Use the Enthought trait's validate.
        """
        return self._validator.validate(obj, name, value)

    def create_editor(self):
        """ User the one in the Enthought trait.
        """
        return self._validator.create_editor()
Example #6
0
class BaseFoo(HasFooView):
    """ A base class that puts some content in the 'foo' dynamic view.
    """

    first = Str('My first name')
    last = Str('My last name')

    # A derived trait set by the handler associated with out dynamic view
    # contribution:
    derived = Str

    ui_person = Group(
        Item(label='On this tab, notice how the sub-handler keeps\n'
             'the derived value equal to the first name.\n\n'
             'On the next tab, change the selection in order to\n'
             'control which tabs are visible when the ui is \n'
             'displayed for the 2nd time.'),
        spring,
        'first',
        'last',
        spring,
        'derived',
        label='My Info',
        _foo_order=5,
        _foo_priority=1,
        _foo_handler=MyInfoHandler(),
    )
Example #7
0
class Explorer(SplitApplicationWindow):
    """ The main application window. """

    #### 'Window' interface ###################################################

    title = Str('Naming System Explorer')

    #### 'SplitApplicationWindow' interface ###################################

    # The direction in which the panel is split.
    direction = Str('vertical')

    # The ratio of the size of the left/top pane to the right/bottom pane.
    ratio = Float(0.3)

    # The root binding (usually a binding to a context!).
    root = Instance(Binding)

    ###########################################################################
    # Protected 'SplitApplicationWindow' interface.
    ###########################################################################

    def _create_lhs(self, parent):
        """ Creates the left hand side or top depending on the style. """

        return self._create_tree(parent, self.root)

    def _create_rhs(self, parent):
        """ Creates the panel containing the selected preference page. """

        return self._create_python_shell(parent)

    ###########################################################################
    # Private interface.
    ###########################################################################

    def _create_tree(self, parent, root):
        """ Creates the tree. """

        self._tree = tree = NamingTree(parent, root=root)

        return tree.control

    def _create_python_shell(self, parent):
        """ Creates the Python shell. """

        self._python_shell = python_shell = PythonShell(parent)

        # Bind useful names.
        python_shell.bind('widget', self._tree)
        python_shell.bind('w', self._tree)
        python_shell.bind('window', self)
        python_shell.bind('explore', explore)

        # Execute useful commands to bind useful names ;^)
        python_shell.execute_command('from enthought.naming.api import *')

        return python_shell.control
Example #8
0
class Hdf5GroupNode(HasTraits):
    name     = Str( '<unknown>' )
    path = Str( '<unknown>' )
    parent_path = Str( '<unknown>' )
    # Can't have recursive traits?  Really?
    #groups = List( Hdf5GroupNode )
    groups = List
    arrays = List( Hdf5ArrayNode )
    groups_and_arrays = List
Example #9
0
class Person(HasTraits): 
    # 'label' is used for Traits UI field labels; 
    # 'desc' can be used for tooltips.
    first_name = Str('', 
                     desc='first or personal name',
                     label='First Name')
    last_name =  Str('', 
                     desc='last or family name', 
                     label='Last Name')
Example #10
0
class IvyDriver(IODriver):
    """
      Ivy input driver.
  """
    _use_thread = False
    _ivy_id = Int(0)

    name = Str('Ivy Driver')
    ivy_agent_name = Str('Plot-o-matic')
    ivy_bus = Str('')
    ivy_ready_msg = Str('READY')
    ivy_regex = Str('(.*)')

    view = View(Item('ivy_agent_name',
                     label='Agent name',
                     editor=TextEditor(enter_set=True, auto_set=False)),
                Item('ivy_bus',
                     label='Ivy bus',
                     editor=TextEditor(enter_set=True, auto_set=False)),
                Item('ivy_regex',
                     label='Regex',
                     editor=TextEditor(enter_set=True, auto_set=False)),
                Item('ivy_ready_msg',
                     label='Ready message',
                     editor=TextEditor(enter_set=True, auto_set=False)),
                title='Ivy input driver')

    def open(self):
        IvyInit(self.ivy_agent_name, self.ivy_ready_msg)
        logging.getLogger('Ivy').setLevel(logging.ERROR)
        IvyStart(self.ivy_bus)
        self._ivy_id = IvyBindMsg(self.on_ivy_msg, self.ivy_regex)

    def close(self):
        IvyUnBindMsg(self._ivy_id)
        IvyStop()

    def reopen(self):
        self.close()
        self.open()

    def _ivy_agent_name_changed(self):
        self.reopen()

    def _ivy_bus_changed(self):
        self.reopen()

    def _ivy_ready_msg_changed(self):
        self.reopen()

    def _ivy_regex_changed(self):
        self.reopen()

    def on_ivy_msg(self, agent, *larg):
        if larg[0] != self.ivy_ready_msg:
            self.pass_data(larg[0])
Example #11
0
class DerivedFoo(BaseFoo):
    """ A derived class that puts additional content in the 'foo' dynamic view.
        Note that the additional content could also have been added via a traits 
        category contribution, or even dynamic manipulation of metadata on a UI
        subelement.  The key is what the metadata represents when the view is
        *created*
    """

    knows_mother = Bool(False)
    mother_first_name = Str("My mother's first name")
    mother_last_name = Str("My mother's last name")

    knows_father = Bool(True)
    father_first_name = Str("My father's first name")
    father_last_name = Str("My father's last name")
    father_derived = Str

    ui_parents = Group(
        'knows_mother',
        'knows_father',
        label='Parents?',
        _foo_order=7,
        _foo_priority=1,
    )

    ui_mother = Group(
        'mother_first_name',
        'mother_last_name',
        label="Mother's Info",
        _foo_priority=1,
    )

    ui_father = Group(
        'father_first_name',
        'father_last_name',
        spring,
        'father_derived',
        label="Father's Info",
        _foo_order=15,
        _foo_priority=1,
        _foo_handler=FatherInfoHandler(),
    )

    def _knows_mother_changed(self, old, new):
        ui_mother = self.trait_view('ui_mother')
        if new:
            ui_mother._foo_order = 10
        elif hasattr(ui_mother, '_foo_order'):
            del ui_mother._foo_order

    def _knows_father_changed(self, old, new):
        ui_father = self.trait_view('ui_father')
        if new:
            ui_father._foo_order = 15
        elif hasattr(ui_father, '_foo_order'):
            del ui_father._foo_order
Example #12
0
class _RegistryData(HasTraits):
    # Object's script ID
    script_id = Property(Str)

    # Path to object in object hierarchy.
    path = Property(Str)

    # Parent data for this object if any.
    parent_data = Instance('_RegistryData', allow_none=True)

    # The name of the trait on the parent which is this object.
    trait_name_on_parent = Str('')

    # List of traits we are listening for on this object.
    names = List(Str)

    # Nested recordable instances on the object.
    sub_recordables = List(Str)

    # List of traits that are lists.
    list_names = List(Str)

    _script_id = Str('')

    ######################################################################
    # Non-public interface.
    ######################################################################
    def _get_path(self):
        pdata = self.parent_data
        path = ''
        if pdata is not None:
            pid = pdata.script_id
            ppath = pdata.path
            tnop = self.trait_name_on_parent
            if '[' in tnop:
                # If the object is a nested object through an iterator,
                # we instantiate it and don't refer to it through the
                # path, this makes scripting convenient.
                if len(ppath) == 0:
                    path = pid + '.' + tnop
                else:
                    path = ppath + '.' + tnop
            else:
                path = ppath + '.' + tnop

        return path

    def _get_script_id(self):
        sid = self._script_id
        if len(sid) == 0:
            pdata = self.parent_data
            sid = pdata.script_id + '.' + self.trait_name_on_parent
        return sid

    def _set_script_id(self, id):
        self._script_id = id
Example #13
0
class Person(HasTraits):
    implements(IName)

    first_name = Str( 'John' )
    last_name  = Str( 'Doe' )

    # Implementation of the 'IName' interface:
    def get_name ( self ):
        """ Returns the name of an object. """
        return ('%s %s' % ( self.first_name, self.last_name ))
class CSurfaceTreeNode(TreeNode):

    # The object that contains the container ;^)
    parent = Any

    # the network associated with this node
    node_for = [CSurface]

    # a default icons
    # Name of group item icon
    icon_group = Str('surface.png')
    # Name of leaf item icon
    icon_item = Str('surface.png')
    # Name of opened group item icon
    icon_open = Str('surface.png')

    # labels
    label = 'dname'

    ###
    # Private Traits

    # activate / deactivate logic
    # if the node is activated, this means that there exists a
    # corresponding RenderManager instance

    _ShowName = Instance(
        Action,
        kw={
            'name': 'Show name',
            'action': 'object.show_name',
            'tooltip': 'Shows the network name'
        },
    )

    # the menu shown after right-click
    menu = Instance(Menu, transient=True)

    def get_children(self, object):
        # this works!
        return object.children

    ######################################################################
    # Non-public interface
    ######################################################################

    def _menu_default(self):
        """ Standard menus for network nodes """

        menu_actions = [Separator()]

        return Menu(*menu_actions)

    def __init__(self, **traits):
        super(CSurfaceTreeNode, self).__init__(**traits)
Example #15
0
class CVolumeTreeNode(TreeNode):

    # The object that contains the container ;^)
    parent = Any

    # the network associated with this node
    node_for = [CVolume]

    # a default icons
    # Name of group item icon
    icon_group = Str('volume.png')
    # Name of leaf item icon
    icon_item = Str('volume.png')
    # Name of opened group item icon
    icon_open = Str('volume.png')

    # labels
    label = 'dname'

    ###
    # Private Traits

    # activate / deactivate logic
    # if the node is activated, this means that there exists a
    # corresponding RenderManager instance

    _VolumeVisualizer = Instance(
        Action,
        kw={
            'name': 'Volume Slicer',
            'action': 'object.vol_vis',
            'tooltip': 'Invokes a simple Volume Slicer by Gael Varoquaux.',
            'enabled_when': 'object.loaded == True'
        },
    )

    # the menu shown after right-click
    menu = Instance(Menu, transient=True)

    def get_children(self, object):
        """ Get the object's children. """
        pass

    ######################################################################
    # Non-public interface
    ######################################################################

    def _menu_default(self):
        """ Standard menus for network nodes """

        menu_actions = [
            Separator(),
        ]

        return Menu(*menu_actions)
Example #16
0
class FilterAdderNode(ListAdderNode):
    """ Tree node that presents a view to the user to add filters.
    """
    # String to be shown in the TreeEditor.
    label = Str('Add a processing filter')

    # The icon of the displayed objects
    icon_name = Str('filter.ico')

    # A reference to the registry, to generate this list.
    items_list_source = registry.filters
class CScriptTreeNode(TreeNode):

    # The object that contains the container ;^)
    parent = Any

    # the network associated with this node
    node_for = [CScript]

    # a default icons
    # Name of group item icon
    icon_group = Str('script.png')
    # Name of leaf item icon
    icon_item = Str('script.png')
    # Name of opened group item icon
    icon_open = Str('script.png')

    # labels
    label = 'dname'

    ###
    # Private Traits

    # activate / deactivate logic
    # if the node is activated, this means that there exists a
    # corresponding RenderManager instance

    _OpenFile = Instance(
        Action,
        kw={
            'name': 'Open File in Editor',
            'action': 'object.open_file',
            'tooltip': 'Open the file in editor'
        },
    )

    # the menu shown after right-click
    menu = Instance(Menu, transient=True)

    def get_children(self, object):
        """ Get the object's children. """
        pass

    ######################################################################
    # Non-public interface
    ######################################################################

    def _menu_default(self):
        """ Standard menus for network nodes """

        menu_actions = [Separator(), \
                        self._OpenFile]

        return Menu(*menu_actions)
Example #18
0
class ExDesignSpec(HasTraits):
    ''' Specification of the experiment design.

    Defines the parameters varied in the experiment design.
    The parameters can be read from the file included in the design.
    '''

    factors = []
    data_converters = {0: fcomma2fdot,
                       1: fcomma2fdot}

    design_file = Str('exdesign_num.csv')
    data_dir = Str('data')
    data_file_name = " '%s %dnm %d.TRA' % (self.embedding, self.torque, self.rep_number ) "
Example #19
0
class aboutBox(HasTraits):
    program = Str("pytimechart: linux traces exploration and visualization")
    author = Str("Pierre Tardy <*****@*****.**>")
    version = Str(__version__)
    doc = Button(__doc__)
    traits_view = View(Item("program", show_label=False, style="readonly"),
                       Item("author", style="readonly"),
                       Item("version", style="readonly"),
                       Item("doc"),
                       width=500,
                       title="about")

    def _doc_changed(self, ign):
        browse_doc()
Example #20
0
class Foo(HasTraits):
    s = Str('foo')
    t = Str('foo.t')

    def _s_changed(self, name, old, new):
        print 'Foo._s_changed( %s, %s, %s, %s)' % (self, name, old, new)
        global foo_s_handler_self
        foo_s_handler_self = self
        return

    def _t_changed(self, name, old, new):
        print 'Foo._t_changed( %s, %s, %s, %s)' % (self, name, old, new)
        global foo_t_handler_self
        foo_t_handler_self = self
        return
Example #21
0
class ClusterTreeNode(BaseGraphTreeNode):
    """ Defines a tree node for Cluster.
    """

    # Name to use for a new instance.
    name = Str( "Cluster" )

    # List of object classes and/or interfaces that the node applies to.
    node_for = [ Cluster ]

    # Name of group item icon.
    icon_group = Str( "cluster" )

    # Name of opened group item icon.
    icon_open = Str( "cluster" )
Example #22
0
class SubgraphTreeNode(BaseGraphTreeNode):
    """ Defines a tree node for Subgraph.
    """

    # Name to use for a new instance.
    name = Str( "Subgraph" )

    # List of object classes and/or interfaces that the node applies to.
    node_for = [ Subgraph ]

    # Name of group item icon.
    icon_group = Str( "subgraph" )

    # Name of opened group item icon.
    icon_open = Str( "subgraph" )
Example #23
0
class Demo(HasName):
    x = Int
    y = Int
    z = Int(monitor=1)  # 有元数据属性monitor的Int
    inner = Instance(Inner)
    alist = List(Int)
    test1 = Str()
    test2 = Str()

    def _inner_default(self):
        return Inner(name="inner1")

    @on_trait_change("x,y,inner.[x,y],test+,+monitor,alist[]")
    def event(self, obj, name, old, new):
        print((obj, name, old, new))
Example #24
0
class TVTKClass(TreeNodeObject):
    children = List()
    name = Str("node")
    doc = Code   
    Classes = {}
    
    def __init__(self, **traits):
        super(TVTKClass, self).__init__(**traits)
        TVTKClass.Classes[self.name] = self
    
    def _get_children(self):
        try:
            subclass_names = SubClasses[self.name]["subclass"]
            subclass_names.sort()
            return [TVTKClass(name=t) for t in subclass_names]
        except:
            return []
    
    def _name_changed(self):
        #self.doc = get_tvtk_class_doc(getattr(tvtk, self.name))
        self.doc = SubClasses[self.name]["doc"]
        self.children = self._get_children()
        
    def tno_get_children(self, node):
        return self.children
Example #25
0
class RemapDemo(HasTraits):
    surf_func = Str()
    func_list = List([
        "np.sqrt(8- x**2 - y**2)",
        "np.sin(6*np.sqrt(x**2+y**2))",
        "np.sin(6*x)",
        "np.sin(6*y)",
        "np.sin(np.sqrt(x**2+y**2))/np.sqrt(x**2+y**2)",
    ])
    range = Range(1.0, 100.0)
    view_height = Range(1.0, 50.0, 10.0)
    grid = Bool(True)

    view = View(Item("surf_func",
                     label="曲面函数",
                     editor=EnumEditor(name="func_list",
                                       auto_set=False,
                                       evaluate=lambda x: x)),
                Item("range", label="曲面范围"),
                Item("view_height", label="视点高度"),
                Item("grid", label="显示网格"),
                title="Remap Demo控制面板")

    def __init__(self, *args, **kwargs):
        super(RemapDemo, self).__init__(*args, **kwargs)
        self.img = cv.imread("lena.jpg")
        self.size = self.img.size()
        self.w, self.h = self.size.width, self.size.height
        self.dstimg = cv.Mat()
        self.map1 = cv.Mat(self.size, cv.CV_32FC1)
        self.map2 = cv.Mat(self.size, cv.CV_32FC1)
        self.gridimg = self.make_grid_img()
        self.on_trait_change(self.redraw, "surf_func,range,view_height,grid")

    def redraw(self):
        def func(x, y):
            return eval(self.surf_func, globals(), locals())

        try:
            self.map1[:], self.map2[:] = make_surf_map(func, self.range,
                                                       self.w, self.h,
                                                       self.view_height)
        except SyntaxError:
            return
        if self.grid:
            img = self.gridimg
        else:
            img = self.img
        cv.remap(img, self.dstimg, self.map1, self.map2, cv.INTER_LINEAR)
        cv.imshow("Remap Demo", self.dstimg)

    def make_grid_img(self):
        img = self.img.clone()
        for i in range(0, self.w, 30):
            cv.line(img, cv.Point(i, 0), cv.Point(i, self.h),
                    cv.CV_RGB(0, 0, 0), 1)
        for i in range(0, self.h, 30):
            cv.line(img, cv.Point(0, i), cv.Point(self.w, i),
                    cv.CV_RGB(0, 0, 0), 1)
        return img
Example #26
0
class Parameter(HasTraits):
    """Defines parameter for FitFunction

    >>> p = Parameter(name = 'a', value = 10.)
    >>> p.name
    'a'
    >>> p.value
    10.0
    """
    #: parameter name
    name = Str()
    #: actual value
    value = Float(1.)
    #: a string representation of value
    value_str = Property(depends_on='value')
    #: sigma of fitted parameter
    sigma = Float(0.)
    #: a string representation of sigma
    sigma_str = Property(depends_on='sigma')
    #: whether it is treated as a constant
    is_constant = Bool(False)

    def _is_constant_changed(self, value):
        if value == True:
            self.sigma = 0.

    def _get_sigma_str(self):
        return ' +/- %f ' % self.sigma

    def _get_value_str(self):
        return ' %f ' % self.value
Example #27
0
class WebPage ( HasTraits ):

    # The URL to display:
    url = Str( 'http://code.enthought.com' )
    
    # The page title:
    title = Str
    
    # The page status:
    status = Str
    
    # The browser navigation buttons:
    back    = Button( '<--' )
    forward = Button( '-->' )
    home    = Button( 'Home' )
    stop    = Button( 'Stop' )
    refresh = Button( 'Refresh' )
    search  = Button( 'Search' )

    # The view to display:
    view = View(
        HGroup( 'back', 'forward', 'home', 'stop', 'refresh', 'search', '_',
                Item( 'status', style = 'readonly' ),
                show_labels = False
        ),
        Item( 'url',
              show_label = False,
              editor     = IEHTMLEditor( 
                               home    = 'home',    back   = 'back', 
                               forward = 'forward', stop   = 'stop', 
                               refresh = 'refresh', search = 'search',
                               title   = 'title',   status = 'status' )
        )
    )
Example #28
0
class InternetExplorerDemo ( HasTraits ):
    
    # A URL to display:
    url = Str( 'http://' )
    
    # The list of web pages being browsed:
    pages = List( WebPage )

    # The view to display:
    view = View(
        VGroup( 
            Item( 'url',
                  label  = 'Location',
                  editor = TextEditor( auto_set = False, enter_set = True )
            )
        ),
        Item( 'pages',
              show_label = False,
              style      = 'custom',
              editor     = ListEditor( use_notebook = True,
                                       deletable    = True,
                                       dock_style   = 'tab',
                                       export       = 'DockWindowShell',
                                       page_name    = '.title' )
        )
    )    
    
    # Event handlers:
    def _url_changed ( self, url ):
        self.pages.append( WebPage( url = url.strip() ) )
class CheckListTest ( Handler ):
    
    #---------------------------------------------------------------------------
    #  Trait definitions:  
    #---------------------------------------------------------------------------
    
    value       = List( editor = CheckListEditor( name = 'values', cols = 5 ) )
    values      = List( Str )
    values_text = Str( 'red orange yellow green blue indigo violet' )
    
    #---------------------------------------------------------------------------
    #  Traits view definitions:  
    #---------------------------------------------------------------------------
        
    simple_view = View( 'value',  'values_text@' )
    custom_view = View( 'value@', 'values_text@' )
                        
    #---------------------------------------------------------------------------
    #  'Initializes the object:  
    #---------------------------------------------------------------------------
                               
    def __init__ ( self, **traits ):
        super( CheckListTest, self ).__init__( **traits )
        self._values_text_changed()
    
    #---------------------------------------------------------------------------
    #  Event handlers:  
    #---------------------------------------------------------------------------
        
    def _values_text_changed ( self ):
        self.values = self.values_text.split()
Example #30
0
class NewModelSelector(HasTraits):
    modelnames = List
    selectedname = Str('No Model')
    modelargnum = Int(2)
    selectedmodelclass = Property
    isvarargmodel = Property(depends_on='modelnames')

    traits_view = View(Item('selectedname',label='Model Name:',editor=EnumEditor(name='modelnames')),
                       Item('modelargnum',label='Extra Parameters:',enabled_when='isvarargmodel'),
                       buttons=['OK','Cancel'])

    def __init__(self,include_models=None,exclude_models=None,**traits):
        super(NewModelSelector,self).__init__(**traits)

        self.modelnames = list_models(include_models,exclude_models,FunctionModel1D)
        self.modelnames.insert(0,'No Model')
        self.modelnames.sort()

    def _get_selectedmodelclass(self):
        n = self.selectedname
        if n == 'No Model':
            return None
        else:
            return get_model_class(n)

    def _get_isvarargmodel(self):
        cls = self.selectedmodelclass

        if cls is None:
            return False
        else:
            return cls.isVarnumModel()
Example #31
0
class MetadataTest(HasTraits):
    i = Int(99, myinfo="test my info")
    s = Str("test", label=u"字符串")
    # NumPy的数组
    a = Array
    # 元素为Int的列表
    list = List(Int)
Example #32
0
    def __init__(self, default_value='', iotype=None, desc=None, 
                 **metadata):

        # Put iotype in the metadata dictionary
        if iotype is not None:
            metadata['iotype'] = iotype
            
        # Put desc in the metadata dictionary
        if desc is not None:
            metadata['desc'] = desc

        self._validator = Enthought_Str(default_value=default_value, **metadata)
            
        super(Str, self).__init__(default_value=default_value, **metadata)