Ejemplo n.º 1
0
class ListTraitTest(HasStrictTraits):

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

    people = List(Person)

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

    traits_view = View(VSplit(Item('people', id='table', editor=table_editor),
                              Item('people@',
                                   id='list',
                                   editor=ListEditor(style='custom', rows=5)),
                              Item('people@',
                                   id='notebook',
                                   editor=ListEditor(use_notebook=True,
                                                     deletable=True,
                                                     export='DockShellWindow',
                                                     page_name='.name')),
                              id='splitter',
                              show_labels=False),
                       title='List Trait Editor Test',
                       id='traitsui.tests.list_traits_ui_test',
                       dock='horizontal',
                       width=.4,
                       height=.6,
                       resizable=True,
                       kind='live')
Ejemplo n.º 2
0
class ListTraitTest(HasStrictTraits):

    # Trait definitions:
    people = List(Instance(Person, ()))

    # Traits view definitions:
    traits_view = View(
        Tabbed(
            Item('people', label='Table', id='table', editor=table_editor),
            Item(
                'people',
                label='List',
                id='list',
                style='custom',
                editor=ListEditor(style='custom', rows=5),
            ),
            Item(
                'people',
                label='Notebook',
                id='notebook',
                style='custom',
                editor=ListEditor(
                    use_notebook=True,
                    deletable=True,
                    export='DockShellWindow',
                    page_name='.name',
                ),
            ),
            id='splitter',
            show_labels=False,
        ),
        id='traitsui.demo.Traits UI Demo.Advanced.List_editors_demo',
        dock='horizontal',
        width=600,
    )
Ejemplo n.º 3
0
 def default_traits_view(self):
     return View(VGroup(
                 Item('beads_name',
                      editor = EnumEditor(name = 'handler.beads_name_choices'),
                      label = "Beads",
                      width = -125),
                 Item('beads_file',
                      width = -125)),
                 VGroup(Item('units_list',
                             editor = ListEditor(editor = InstanceEditor(view = self.unit_traits_view()),
                                                 style = 'custom',
                                                 mutable = False),
                             style = 'custom'),
                 Item('handler.add_channel',
                      editor = ButtonEditor(value = True,
                                            label = "Add a channel")),
                 Item('handler.remove_channel',
                      editor = ButtonEditor(value = True,
                                            label = "Remove a channel")),
                 label = "Controls",
                 show_labels = False),
                 Item('bead_peak_quantile',
                      label = "Peak\nQuantile"),
                 Item('bead_brightness_threshold',
                      label = "Peak\nThreshold "),
                 Item('bead_brightness_cutoff',
                      label = "Peak\nCutoff"),
                 Item('context.do_estimate',
                      editor = ButtonEditor(value = True,
                                            label = "Estimate!"),
                      show_label = False),
                 shared_op_traits)
Ejemplo n.º 4
0
 def _view_tabs(self):
     return UItem('groups',
                  style='custom',
                  editor=ListEditor(use_notebook=True,
                                    style='custom',
                                    selected='selected_group',
                                    page_name='.label'))
Ejemplo n.º 5
0
    def traits_view(self):
        egrp = VGroup(HGroup(Item('ex'), Item('ey')),
                      BorderHGroup(icon_button_editor('increment_down_x', 'arrow_left'),
                                   icon_button_editor('increment_up_x', 'arrow_right'),
                                   UItem('x_magnitude'),
                                   label='X'),
                      BorderHGroup(icon_button_editor('increment_up_y', 'arrow_up'),
                                   icon_button_editor('increment_down_y', 'arrow_down'),
                                   UItem('y_magnitude'),
                                   label='Y'),
                      BorderHGroup(UItem('width'),
                                   icon_button_editor('width_increment_minus_button', 'delete'),
                                   icon_button_editor('width_increment_plus_button', 'add'), label='Width'),
                      BorderHGroup(UItem('height'),
                                   icon_button_editor('height_increment_minus_button', 'delete'),
                                   icon_button_editor('height_increment_plus_button', 'add'), label='Height'),


                      UItem('save_button'))

        g = VGroup(UItem('groups', style='custom',
                         editor=ListEditor(use_notebook=True,
                                           page_name='.name',
                                           selected='selected_group',
                                           editor=InstanceEditor())))

        v = View(VGroup(g, egrp))
        return v
Ejemplo n.º 6
0
class AppNotebookView ( HasPrivateTraits ):

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

    # The list of objects to display:
    objects = List

    # The list of NotebookItems corresponding to the list of objects:
    items = List

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

    traits_view = View(
        Item( 'items@',
              show_label = False,
              editor     = ListEditor( use_notebook = True,
                                       deletable    = True,
                                       page_name    = '.name',
                                       export       = 'DockWindowShell',
                                       dock_style   = 'tab' )
        )
    )

    #---------------------------------------------------------------------------
    #  Handles the 'objects' trait being changed:
    #---------------------------------------------------------------------------

    def _objects_changed ( self, objects ):
        """ Handles the 'objects' trait being changed.
        """
        self.items = [ NotebookItem( object = object ) for object in objects ]
Ejemplo n.º 7
0
def listeditor(name, **kw):
    return Item(name,
                show_label=False,
                editor=ListEditor(mutable=False,
                                  style='custom',
                                  editor=InstanceEditor()),
                **kw)
    def traits_view(self):
        """
        """
        cgrp = VGroup(
            Item('axes',
                 style='custom',
                 show_label=False,
                 editor=ListEditor(use_notebook=True,
                                   dock_style='tab',
                                   page_name='.name',
                                   selected='selected',
                                   view='full_view')),
            HGroup(spring,
                   Item('load_button'),
                   Item('read_button'),
                   Item('apply_button'),
                   show_labels=False))

        tgrp = VGroup(
            HGroup(UItem('xmove_to_button'), UItem('xtarget_position')),
            HGroup(UItem('ymove_to_button'), UItem('ytarget_position')))

        view = View(
            VGroup(tgrp, cgrp),
            resizable=True,
            handler=self.handler_klass,  # MotionControllerManagerHandler,
            title='Configure Motion Controller')
        return view
Ejemplo n.º 9
0
 def default_traits_view(self):
     return View(Group(Group(Item('open_file', style='custom'),
                   show_labels=False, show_border=False),
                   Item('items_list', style='readonly',
                         editor=ListEditor(style='custom')),
                   show_labels=False,
                   label='Add a data source'))
Ejemplo n.º 10
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()))
Ejemplo n.º 11
0
    def traits_view(self):
        cview = View(
            VGroup(
                CustomLabel('message',
                            size=14,
                            weight='bold',
                            color_name='message_color'),
                HGroup(
                    Spring(width=-5, springy=False),
                    Item('high', label='Set Max. Seconds'), spring,
                    CustomLabel('current_display_time', size=24,
                                weight='bold'), UItem('pause_button'),
                    UItem('continue_button'))))

        # HGroup(Spring(width=-5, springy=False),
        #        Item('current_time', show_label=False,
        #             editor=RangeEditor(mode='slider', low=1, high_name='duration')))))

        v = View(
            UItem('active_control',
                  style='custom',
                  visible_when='single',
                  editor=InstanceEditor(view=cview)),
            UItem('controls',
                  editor=ListEditor(use_notebook=True,
                                    selected='active_control',
                                    page_name='.page_name',
                                    view=cview),
                  style='custom',
                  visible_when='not single'))
        return v
Ejemplo n.º 12
0
def list_editor(trait, handler):
    """ Factory that constructs an appropriate editor for a list.
    """
    item_handler = handler.item_trait.handler
    if _expects_hastraits_instance(item_handler):
        from traitsui.table_column import ObjectColumn
        from traitsui.table_filter import (EvalFilterTemplate,
                                           RuleFilterTemplate,
                                           MenuFilterTemplate, EvalTableFilter)
        from traitsui.api import TableEditor

        return TableEditor(filters=[
            RuleFilterTemplate, MenuFilterTemplate, EvalFilterTemplate
        ],
                           edit_view='',
                           orientation='vertical',
                           search=EvalTableFilter(),
                           deletable=True,
                           show_toolbar=True,
                           reorderable=True,
                           row_factory=_instance_handler_factory(item_handler))
    else:
        from traitsui.api import ListEditor

        return ListEditor(trait_handler=handler,
                          rows=trait.rows if trait.rows else 5,
                          use_notebook=bool(trait.use_notebook),
                          page_name=trait.page_name if trait.page_name else '')
Ejemplo n.º 13
0
 def traits_view(self):
     return View(HSplit(VGroup(Item('library',
                                    show_label=False,
                                    style='custom',
                                    editor=InstanceEditor()),
                               label='Library Manager',
                               group_theme='@std:GL5TB',
                               dock='horizontal'),
                        VGroup(Item('items',
                                    id='items',
                                    show_label=False,
                                    style='custom',
                                    editor=ListEditor(
                                        use_notebook=True,
                                        deletable=True,
                                        page_name='.name',
                                        export='DockWindowShell',
                                        dock_style='tab')),
                               label=self.editor_title,
                               group_theme='@std:GL5TB',
                               dock='horizontal'),
                        group_theme='@std:XG0',
                        id='splitter'),
                 id=self.editor_id,
                 width=0.7,
                 height=0.5,
                 resizable=True)
Ejemplo n.º 14
0
 def traits_view(self):
     v = View(VSplit(
         VGroup(
             UItem('filters',
                   editor=ListEditor(editor=InstanceEditor(),
                                     mutable=False,
                                     style='custom')),
             HGroup(
                 spring, UItem('apply_filter_button',
                               label='Apply Filters'),
                 Item('omit',
                      label='Omit',
                      tooltip='Omit analyses instead of exclude'))),
         VGroup(
             HGroup(CustomLabel('nitems', color='maroon'),
                    CustomLabel('nfiltered', color='green')),
             UItem('items',
                   editor=myTabularEditor(adapter=UnknownsAdapter(),
                                          refresh='refresh_needed')))),
              resizable=True,
              handler=TableFilterHandler(),
              buttons=['OK', 'Cancel', 'Revert'],
              height=500,
              width=500,
              title='Filter Analyses')
     return v
Ejemplo n.º 15
0
 def default_traits_view(self):
     return View(
         VGroup(Item('controls_list',
                     editor=ListEditor(editor=InstanceEditor(
                         view=self.control_traits_view()),
                                       style='custom',
                                       mutable=False),
                     style='custom'),
                Item('handler.add_control',
                     editor=ButtonEditor(value=True,
                                         label="Add a control")),
                Item('handler.remove_control',
                     editor=ButtonEditor(value=True,
                                         label="Remove a control")),
                label="Controls",
                show_labels=False),
         Item('mixture_model', label="Use mixture\nmodel?"),
         VGroup(Item(
             'subset_dict',
             show_label=False,
             editor=SubsetEditor(
                 conditions="context.previous.conditions",
                 metadata="context.previous.metadata",
                 when="'experiment' not in vars() or not experiment")),
                label="Subset",
                show_border=False,
                show_labels=False),
         Item('context.do_estimate',
              editor=ButtonEditor(value=True, label="Estimate!"),
              show_label=False), shared_op_traits)
Ejemplo n.º 16
0
class codeEditor(HasTraits):

    # number of images
    n_img = Int()

    oriEditors = List

    # view
    traits_view = View(Item('oriEditors',
                            style='custom',
                            editor=ListEditor(
                                use_notebook=True,
                                deletable=False,
                                dock_style='tab',
                                page_name='.file_Path',
                            ),
                            show_label=False),
                       buttons=['Cancel'],
                       title='Camera\'s orientation files')

    def __init__(self, path):
        # load ptv_par
        ptvParams = par.PtvParams(path=path)
        ptvParams.read()
        self.n_img = ptvParams.n_img

        # load cal_ori
        calOriParams = par.CalOriParams(self.n_img, path=path)
        calOriParams.read()

        for i in range(self.n_img):
            self.oriEditors.append(oriEditor(get_path(
                calOriParams.img_ori[i])))
Ejemplo n.º 17
0
    def traits_view(self):
        """ Build the dynamic dialog view.
        """
        buttons = ["OK", "Cancel"]
        if self.show_apply:
            buttons = ["Apply"] + buttons

        # Only show the tab bar if there is more than one category.
        tabs_style = "custom" if len(self._tabs) > 1 else "readonly"

        return View(
            Item(
                "_tabs",
                editor=ListEditor(
                    page_name=".name",
                    style="custom",
                    use_notebook=True,
                    selected="_selected",
                ),
                show_label=False,
                style=tabs_style,
            ),
            buttons=buttons,
            kind="livemodal",
            resizable=True,
            title="Preferences",
        )
Ejemplo n.º 18
0
class PikosTaskPane(TraitsTaskPane):

    #### 'ITaskPane' interface ################################################

    id = 'pikos.live.ui.pikos_task_pane'
    name = 'Pikos Task Pane'

    #### 'MemoryPane' interface ###############################################

    tabs = List

    def _tabs_default(self):
        return [IntroTab()]

    def _make_new_tab_title(self, model):
        return str(model.pid)

    def add_tab(self, model):
        title = self._make_new_tab_title(model)
        view_class = get_view_for_profile(model.profile)
        tab = view_class(title=str(model.pid), model=model)
        self.tabs.append(tab)

    traits_view = View(
        UItem(
            'tabs@',
            editor=ListEditor(
                use_notebook=True,
                deletable=False,
                page_name='.title',
            ),
        ),
        resizable=True,
    )
Ejemplo n.º 19
0
class sequence(HasTraits):

    name = Str

    file = File()

    waveforms = List()

    digi_num = Int()

    analog_num = Int()

    load = Button('Load')

    reload = Button('Reload')

    view = View(
        Item('file'), Item('load'), Item('reload'),
        VGroup(Item('waveforms',
                    style='custom',
                    editor=ListEditor(use_notebook=True,
                                      deletable=True,
                                      dock_style='tab',
                                      page_name='.name')),
               show_labels=False,
               show_border=True,
               label='Waveforms'))

    def _load_fired(self):

        seq = parse_seq(self.file)

        self.waveforms = []

        self.waveforms.append(
            waveform(name='Digital',
                     channels=seq.digi_channels,
                     time=seq.digi_time,
                     data=seq.digi_data))

        for i, analog in enumerate(seq.analog_channels):

            self.waveforms.append(
                waveform(name='Analog%d' % i,
                         channels=analog,
                         time=seq.analog_time[i],
                         data=seq.analog_data[i]))

    def _reload_fired(self):

        seq = parse_seq(self.file)

        self.waveforms[0].data = seq.digi_data
        self.waveforms[0].time = seq.digi_time

        for i, analog in enumerate(seq.analog_channels):

            self.waveforms[i + 1].data = seq.analog_data[i]
            self.waveforms[i + 1].time = seq.analog_time[i]
Ejemplo n.º 20
0
class MCMC_1(HasTraits):
	parameters = List
	iter = Int(10000)
	thin = Int(2)
	burn_in = Int(0)
	run = Button("Run")
	prior_dict = dict()
	status = Str('')

	view = View(
		Item( 'parameters',
			style  = 'custom',
			editor = ListEditor( use_notebook = True,
				deletable    = True,
				dock_style   = 'tab',
				page_name    = '.name' )
		),

		Item('iter'),
		Item('burn_in'),
		Item('thin'),
		Item('run'),
		Label('See log file for ouput'),
		title   = 'MCMC', resizable=True,
		buttons = [ 'OK', 'Cancel' ]
	)

	def _run_fired(self):
		for i in range(len(self.parameters)):

			#Sets a Poisson Distribution
			if self.parameters[i].dist=='Poisson':
				self.prior_dict[self.parameters[i].name]=0

			#Sets a Normal Distribution
			if self.parameters[i].dist=='Uniform':
				self.prior_dict[self.parameters[i].name]=(self.parameters[i].min,self.parameters[i].max)

			#Sets a Normal Distribution
			if self.parameters[i].dist=='Normal':
				self.prior_dict[self.parameters[i].name]=self.parameters[i].sig

		x,y,w = Data.tracefitmodel.data
		model = Data.tracefitmodel.getMCMC(x,y,priors=self.prior_dict,datamodel=None)
		model_fit = MAP(model)
		Data.mcmc = {}
		model_fit.fit()
		Data.mcmc['MAP'] = model_fit.BIC
		MC = pymc.MCMC(model_fit.variables)
		MC.sample(self.iter,burn=self.burn_in,thin=self.thin)
		#for i in Data.tracefitmodel.parms:
		#	Data.mcmc[i] = MC.stats()[i]
		Data.mcmc['MCMC'] = MC

		for i in range(len(self.parameters)):
			if self.parameters[i].plot==True:
				Matplot.plot(MC.trace(self.parameters[i].name))

		plt.show()
Ejemplo n.º 21
0
 def default_traits_view(self):
     """Provides view with display information for commands
     trait"""
     command_editor = ListEditor(mutable=False, style="custom")
     output_editor = ListEditor(mutable=False)
     return View(
         Group(Item('case_files'),
               Item('time_steps'),
               Item('host'),
               Item('port'),
               label='General'),
         Group(Item('n_commands'),
               Item('commands', editor=command_editor),
               label='Generators/Solvers'),
         Group(Item('n_outputs'),
               Item('outputs', editor=output_editor),
               label='Output files'))
Ejemplo n.º 22
0
    def traits_view(self):
        v = View(UItem('loggers',
                       editor=ListEditor(use_notebook=True,
                                         page_name='.title',
                                         selected='selected'),
                       style='custom'))

        return v
Ejemplo n.º 23
0
class MCMC(HasTraits):
    parameters = List
    iter = Int(10000)
    burn_in = Int(0)
    run = Button("Run")
    prior_dict = dict()
    status = Str('')

    view = View(Item('parameters',
                     style='custom',
                     editor=ListEditor(use_notebook=True,
                                       deletable=True,
                                       dock_style='tab',
                                       page_name='.name')),
                Item('iter'),
                Item('burn_in'),
                Item('run'),
                Label('See log file for ouput'),
                title='MCMC',
                resizable=True,
                buttons=['OK', 'Cancel'])

    def _run_fired(self):
        """

		"""
        for i in range(len(self.parameters)):

            #Sets a Poisson Distribution
            if self.parameters[i].dist == 'Poisson':
                self.prior_dict[self.parameters[i].name] = 0

            #Sets a Normal Distribution
            if self.parameters[i].dist == 'Uniform':
                self.prior_dict[self.parameters[i].name] = (
                    self.parameters[i].min, self.parameters[i].max)

            #Sets a Normal Distribution
            if self.parameters[i].dist == 'Normal':
                self.prior_dict[
                    self.parameters[i].name] = self.parameters[i].sig

        print("dictionary created")
        print(self.prior_dict)

        x, y, w = Data.tracefitmodel.data
        model = Data.tracefitmodel.getMCMC(x,
                                           y,
                                           priors=self.prior_dict,
                                           datamodel=None)

        model.sample(self.iter, burn=self.burn_in)

        Matplot.plot(model)
        plt.show()
        model.stats()

        return (self.status)
Ejemplo n.º 24
0
class Hotel(HasPrivateTraits):

    # The season of the year:
    season = Enum('Winter', 'Spring', 'Summer', 'Fall')

    # The current cost of heating fuel (in dollars/gallon):
    fuel_cost = Range(2.00, 10.00, 4.00)

    # The current minimum temparature allowed by the hotel:
    min_temperature = Property(depends_on='season, fuel_cost')

    # The guests currently staying at the hotel:
    guests = List  # ( Instance( 'Guest' ) )

    # Add a new guest to the hotel:
    add_guest = Button('Add Guest')

    # The view of the hotel:
    view = View(VGroup(
        HGroup(Item('season'),
               '20',
               Item('fuel_cost', width=300),
               spring,
               Item('add_guest', show_label=False),
               show_border=True,
               label='Hotel Information'),
        VGroup(Item('guests',
                    style='custom',
                    editor=ListEditor(use_notebook=True,
                                      deletable=True,
                                      dock_style='tab',
                                      page_name='.name')),
               show_labels=False,
               show_border=True,
               label='Guests')),
                title='The Belmont Hotel Dashboard',
                width=0.6,
                height=0.2,
                resizable=True)

    # Property implementations:
    @cached_property
    def _get_min_temperature(self):
        return ({
            'Winter': 32,
            'Spring': 40,
            'Summer': 45,
            'Fall': 40
        }[self.season] + min(int(60.00 / self.fuel_cost), 15))

    # Event handlers:
    @on_trait_change('guests[]')
    def _guests_modified(self, removed, added):
        for guest in added:
            guest.hotel = self

    def _add_guest_changed(self):
        self.guests.append(Guest())
Ejemplo n.º 25
0
 def traits_view(self):
     v = View(
         Item('channels',
              show_label=False,
              height=400,
              editor=ListEditor(mutable=False,
                                editor=InstanceEditor(),
                                style='custom')))
     return v
Ejemplo n.º 26
0
class CategoricalMCOParameter(BaseMCOParameter):
    """ Categorical MCO Parameter implements unordered, discrete valued,
    categorical data. Available categorical values are strings. """

    categories = List(Str, editor=ListEditor())
    sample_values = Property(depends_on="categories", visible=False)

    def _get_sample_values(self):
        return self.categories
Ejemplo n.º 27
0
 def default_traits_view(self):
     return View(Item('_to_edit',
                      editor=ListEditor(use_notebook=True, page_name='.section_name'),
                      style='custom',
                      show_label=False),
                 title=self.title,
                 resizable=True,
                 handler=PreferenceHandler(),
                 buttons=[OKButton, CancelButton])
Ejemplo n.º 28
0
 def _flag_item_factory(self, name, label):
     return Group(Item(name,
                       show_label=False,
                       style='readonly',
                       editor=ListEditor(
                           editor=InstanceEditor(editable=True),
                           style='custom')),
                  show_border=True,
                  label=label)
Ejemplo n.º 29
0
 def gauge_view(self):
     v = View(Group(Item('gauges', style='custom',
                         show_label=False,
                         editor=ListEditor(mutable=False,
                                           style='custom',
                                           editor=InstanceEditor())),
                    show_border=True,
                    label=self.display_name))
     return v
Ejemplo n.º 30
0
 def default_traits_view(self):
     view = View(Item(
         'people',
         label='List',
         id='list',
         style=self.style,
         editor=ListEditor(style=self.style, columns=self.num_columns),
     ),
                 resizable=True)
     return view