當前位置: 首頁>>代碼示例>>Python>>正文


Python api.HasTraits類代碼示例

本文整理匯總了Python中enthought.traits.api.HasTraits的典型用法代碼示例。如果您正苦於以下問題:Python HasTraits類的具體用法?Python HasTraits怎麽用?Python HasTraits使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HasTraits類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

    def __init__(self, parent=None, manage_overlay=True, **traits):
        HasTraits.__init__(self, **traits)
        self.master_src # instantiates default master_src and blender
        self.func_man
        from xipy.vis.mayavi_widgets.overlay_blending import ImageBlendingComponent
        from xipy.vis.mayavi_widgets.overlay_thresholding_surface import OverlayThresholdingSurfaceComponent
        from xipy.vis.mayavi_widgets.cortical_surface import CorticalSurfaceComponent
        from xipy.vis.mayavi_widgets.translated_planes import TranslatedPlanes

        # set up components
        self.vis_helpers.append(
            ImageBlendingComponent(self, manage_overlay)
            )
        self.vis_helpers.append(
            TranslatedPlanes(self)
            )
        self.vis_helpers.append(
            OverlayThresholdingSurfaceComponent(self)
            )

        self.vis_helpers.append(
            CorticalSurfaceComponent(self)
            )
                        
        
        anat_alpha = np.ones(256)
        anat_alpha[:5] = 0
        self.blender.set(main_alpha=anat_alpha, trait_notify_change=False)
        self.__reposition_planes_after_interaction = False
開發者ID:cindeem,項目名稱:xipy,代碼行數:29,代碼來源:ortho_viewer_3d.py

示例2: __init__

 def __init__(self, source, **traits):
     HasTraits.__init__(self, **traits)
     nTs = self.time.shape[0]
     if isinstance(source, HasTraits):
         self.traited = True
         self.tracking = source.traits(track=True).keys()
         for attr in self.tracking:
             shape = (nTs,)
             if type(getattr(source, attr)) is _numpy.ndarray:
                 shape += getattr(source, attr).shape
             self.data[attr] = _numpy.zeros(shape, "d")
     else:
         if type(source) is type([]):
             self.tracking = source
             for var in source:
                 self.data[var] = _numpy.zeros((nTs,), "d")
             self._update = _copy(source)
         elif type(source) is type({}):
             self.tracking = source.keys()
             for var in self.tracking:
                 shape = (nTs,) + tuple(source[var])
                 self.data[var] = _numpy.zeros(shape, "d")
             self._update = _copy(self.tracking)
         else:
             raise TypeError, self.__class__.__doc__
     self.source = source
開發者ID:jdmonaco,項目名稱:grid-remapping-model,代碼行數:26,代碼來源:timeseries.py

示例3: handle_arguments

  def handle_arguments(self,*args,**kwargs): 
    HasTraits.__init__(self)		#magic by fnoble
    for a in args:
      if isinstance(a,Frame):
        self.parent=a
    for k,v in kwargs.items():
      if k == 'frame':
        self.parent=v
      elif k == 'T':
         if isinstance(v,Expression):
           self.T=v
         else:
           self.T=self.parent.variables.new_expression(v)
      elif len(self.trait_get(k))>0:
         #self.trait_set({k:v})
         self.__setattr__(k,v)
      elif len(self.actor.trait_get(k))>0:
         self.actor.__setattr__(k,v)
      elif len(self.properties.trait_get(k))>0:
         self.properties.__setattr__(k,v)
      elif len(self.source.trait_get(k))>0:
         self.source.__setattr__(k,v)
      else :
         print "unknown argument", k , v

    if not(self.parent):
      self.parent = WorldFrame()
開發者ID:jgillis,項目名稱:Plot-o-matic,代碼行數:27,代碼來源:Primitives.py

示例4: __init__

    def __init__(self, fgcolor=(0.0, 0.0, 0.0), bgcolor=(1.0, 1.0, 1.0),
                 **traits):
        HasTraits.__init__(self, **traits)
        scene = self.scene.scene

        scene.foreground = fgcolor
        scene.background = bgcolor
開發者ID:snilek,項目名稱:sfepy,代碼行數:7,代碼來源:viewer.py

示例5: _showerror_fired

 def _showerror_fired(self,evt):
     if self.tmodel.lastfitfailure:
         ex = self.tmodel.lastfitfailure
         dialog = HasTraits(s=ex.__class__.__name__+': '+str(ex))
         view = View(Item('s',style='custom',show_label=False),
                     resizable=True,buttons=['OK'],title='Fitting error message')
         dialog.edit_traits(view=view)
開發者ID:keflavich,項目名稱:astropy-fitgui,代碼行數:7,代碼來源:fitgui.py

示例6: __init__

 def __init__(self, pos_data, **traits):
     """Required first argument is the 4-column data array from a Pos.p file
     """
     HasTraits.__init__(self, **traits)
     if not (pos_data[:,-1] == -99).all():
         valid = (pos_data[:,-1] != -99).nonzero()[0]
         pos_data = pos_data[valid]
     self.t, self.x, self.y, self.angle = pos_data.T
開發者ID:jdmonaco,項目名稱:vmo-feedback-model,代碼行數:8,代碼來源:circle_track.py

示例7: __init__

 def __init__(self, condition, avg_beams, stats_results, **traits):
     HasTraits.__init__(self, **traits)
     self._avg_dict = {}
     self.stats_results = stats_results
     
     for c, b in zip(condition, avg_beams):
         self._avg_beams.append(str(c))
         self._avg_dict[str(c)] = b
開發者ID:christandiono,項目名稱:nutmeg-py,代碼行數:8,代碼來源:stats_ui.py

示例8: __init__

 def __init__(self, *args, **kw):
     HasTraits.__init__(self, *args, **kw)
     numpoints = 200
     plotdata = ArrayPlotData(x=sort(random(numpoints)), y=random(numpoints))
     plot = Plot(plotdata)
     plot.plot(("x", "y"), type="scatter")
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.plot = plot
開發者ID:brycehendrix,項目名稱:chaco,代碼行數:9,代碼來源:aspect_ratio.py

示例9: __init__

    def __init__(self, **traits):
        HasTraits.__init__(self, **traits)
        self.engine_view = EngineView(engine=self.scene.engine)

        # Hook up the current_selection to change when the one in the engine
        # changes.  This is probably unnecessary in Traits3 since you can show
        # the UI of a sub-object in T3.
        self.scene.engine.on_trait_change(self._selection_change,
                                          'current_selection')
開發者ID:axelvonderheide,項目名稱:scratch,代碼行數:9,代碼來源:mesh_actors.py

示例10: __init__

 def __init__ ( self, object, name, index, trait, value ):
     HasTraits.__init__( self )
     self.inited = False
     self.object = object
     self.name   = name
     self.index  = index
     if trait is not None:
         self.add_trait( 'value', trait )
         self.value  = value
     self.inited = True
開發者ID:gkliska,項目名稱:razvoj,代碼行數:10,代碼來源:list_editor.py

示例11: __init__

 def __init__(self, *args, **kw):
     HasTraits.__init__(self, *args, **kw)
     # Create the data and the PlotData object
     x = linspace(-14, 14, 100)
     y = sin(x) * x**3
     plotdata = ArrayPlotData(x = x, y = y)
     # Create the scatter plot
     plot = Plot(plotdata)
     plot.plot(("x", "y"), type=self.plot_type, color="blue")
     plot.tools.append(PanTool(plot))
     plot.tools.append(ZoomTool(plot))
     self.plot = plot
開發者ID:brycehendrix,項目名稱:chaco,代碼行數:12,代碼來源:connected_widgets.py

示例12: __init__

    def __init__(self, **traits):
        HasTraits.__init__(self, **traits)
        
        try:
            if not path.exists(self.datadir):
                makedirs(self.datadir)
        except OSError:
            self.out('Reverting to base directory:\n%s'%ANA_DIR, error=True)
            self.datadir = ANA_DIR
        finally:
            self.datadir = path.abspath(self.datadir)

        self.out('%s initialized:\n%s'%(self.__class__.__name__, str(self)))
開發者ID:jdmonaco,項目名稱:grid-remapping-model,代碼行數:13,代碼來源:analysis.py

示例13: __init__

 def __init__(self, pmap, **traits):
     HasTraits.__init__(self, **traits)
     try:
         self.PMap = pmap
     except TraitError:
         self.out('PlaceMap subclass instance required', error=True)
         return
     self.fdata = self.PMap.get_field_data()
     self.udata = self.PMap.get_unit_data()
     self.add_trait('unit', Range(low=0, high=self.PMap.num_maps-1))
     self._update_unit_values()
     self.out('Bringing up place-map visualization...')
     self.view()
     self.out('Done!')
開發者ID:jdmonaco,項目名稱:grid-remapping-model,代碼行數:14,代碼來源:placemap_viewer.py

示例14: __init__

 def __init__(self, eval=None, label='Value',
              trait=None, min=0.0, max=1.0,
              initial=None, **traits):
     HasTraits.__init__(self, **traits)
     if trait is None:
         if min > max:
             min, max = max, min
         if initial is None:
             initial = min
         elif not (min <= initial <= max):
             initial = [min, max][
                 abs(initial - min) >
                 abs(initial - max)]
         trait = Range(min, max, value=initial)
     self.add_trait(label, trait)
開發者ID:rayyeh,項目名稱:python-ray,代碼行數:15,代碼來源:object_trait_attrs.py

示例15: __init__

 def __init__(self, *l, **kw):
     # TODO: implement aspect ratio maintaining
     HasTraits.__init__(self, *l, **kw)
     #self.plotdata = ArrayPlotData(x=self.pointsx, y=self.pointsy)
     plot = Plot(self.plotdata)
     plot.plot(("x", "y"))
     plot.plot(("x", "y"), type='scatter')
     
     plot.tools.append(PanTool(plot, drag_button='left'))
     plot.tools.append(ZoomTool(plot, tool_mode='box'))
     plot.tools.append(DragZoom(plot, tool_mode='box', drag_button='right'))
     plot.tools.append(CustomSaveTool(plot))#, filename='/home/pankaj/Desktop/file.png'))
     plot.tools.append(TraitsTool(plot))
     self.plot = plot
     self.set_plotdata()
開發者ID:ArtemyVI,項目名稱:pyavl,代碼行數:15,代碼來源:output_viewer.py


注:本文中的enthought.traits.api.HasTraits類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。