How to use the traitsui.api.TableEditor function in traitsui

To help you get started, we’ve selected a few traitsui 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 enthought / traitsui / integrationtests / ui / table_editor_focus_bug.py View on Github external
def _input_changed(self):
        words = self.input.split()

        for word in self.parsed[:]:
            if word.word in words:
                words.remove(word.word)
            else:
                self.parsed.remove(word)

        for word in words:
            self.parsed.append(Word(word=word))

        return

    table_editor = TableEditor(
        columns=[ObjectColumn(name='word')],
        editable=True)

    help = Str("""Type in the 'input' box before clicking the Parsed tab.
The first non-whitespace character will cause changes to the parsed trait
and therefore changes to the table rows.  That is expected.

BUG: the table grabs the focus from 'input' and thus subsequent typing goes
into one of the table cells.

If you click the 'Parsed' tab, to view the table, and then the 'Inputs' tab
the focus will stay with the 'input' box.
""")

    traits_view = View(
        Group(Item('help', style='readonly'),
github NMGRL / pychron / pychron / processing / tasks / flux / flux_editor.py View on Github external
column(name='j', label='Pred. J',
                   format_func=lambda x: floatfmt(x, n=8, s=4),
                   width=75),
            column(name='jerr',
                   format_func=lambda x: floatfmt(x, n=10, s=4),
                   label=u'\u00b1\u03c3',
                   width=75),
            column(name='percent_pred_error',
                   label='%',
                   format_func=lambda x: floatfmt(x, n=2) if x else ''),
            column(name='dev', label='dev',
                   format='%0.2f',
                   width=70),
            column(klass=CheckboxColumn, name='save', label='Save', editable=True, width=30)]

        editor = TableEditor(columns=cols, sortable=False,
                             reorderable=False)

        jfloatfmt = lambda x: floatfmt(x, n=2)
        v = View(VSplit(
            UItem('graph',
                  style='custom',
                  editor=InstanceEditor(), height=0.72),
            VGroup(HGroup(UItem('recalculate_button'),
                          Item('min_j', format_str='%0.4e',
                               style='readonly',
                               label='Min. J'),
                          Item('max_j',
                               style='readonly',
                               format_str='%0.4e', label='Max. J'),
                          Item('percent_j_change',
                               style='readonly',
github NMGRL / pychron / pychron / experiment / conflict_resolver.py View on Github external
def traits_view(self):
        cols = [ObjectColumn(name='queue_name', editable=False),
                ObjectColumn(name='identifier', editable=False),
                ObjectColumn(name='position', editable=False),
                ObjectColumn(name='repository_identifier',
                             label='Repository',
                             tooltip='Repository assigned to this analysis in the Experiment Queue',
                             editor=myEnumEditor(name='available_ids')),
                ObjectColumn(name='repository_ids',
                             label='Existing Repositories',
                             tooltip='Set of repositories that already contain this L#',
                             editable=False)]

        v = View(UItem('conflicts', editor=TableEditor(columns=cols)),
                 title='Resolve Experiment Conflicts',
                 resizable=True,
                 buttons=['OK', 'Cancel'])
        return v
github NMGRL / pychron / pychron / spectrometer / tasks / mass_cal / panes.py View on Github external
def traits_view(self):
        cols = [ObjectColumn(name='isotope',
                             editor=EnumEditor(name='isotopes')),
                ObjectColumn(name='dac')]
        return View(
            UItem('object.scanner.calibration_peaks',
                  editor=TableEditor(columns=cols,
                                     selected='object.scanner.selected')
            )
github enthought / traits / traits / traits.py View on Github external
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
github MatthieuDartiailh / HQCMeas / measurement / task_management / tasks / save_tasks.py View on Github external
"""
        """
        line_completer = LineCompleterEditor(
                             entries_updater = self._list_database_entries)
        label_col = ObjectColumn(name = 'label',
                         label = 'Label',
                         horizontal_alignment = 'center',
                         width = 0.4,
                         )
        value_col = ObjectColumn(name = 'value',
                         label = 'Value',
                         horizontal_alignment = 'center',
                         editor = line_completer,
                         width = 0.6,
                         )
        table_editor = TableEditor(
                editable  = True,
                sortable  = False,
                auto_size = False,
                reorderable = True,
                deletable = True,
                row_factory = SavedValueObject,
                columns = [label_col,
                            value_col],
                )
        view = View(
                UItem('task_name', style = 'readonly'),
                VGroup(
                    HGroup(
                        Label('Save to :'),
                        UItem('saving_target'),
                        ),
github bright-dev / bright / bright / gui / views / component_views / material.py View on Github external
isotope = Str

    #mass_weight = Range(0.0, np.inf, 0.0)
    mass_weight = Float(0.0)

# Mass Stream isotopic filters
UFilter   = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 == 92,        name='Uranium')
PUFilter  = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 == 94,        name='Plutonium')
LANFilter = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 in isoname.lan, name='Lanthanides')
ACTFilter = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 in isoname.act, name='Actinides')
TRUFilter = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 in isoname.tru, name='Transuranics')
MAFilter  = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 in isoname.ma,  name='Minor Actinides')
FPFilter  = TableFilter(allowed=lambda x: nucname.zzaam(str(x.isotope))/10000 in isoname.fp,  name='Fission Products')


material_editor = TableEditor(
    columns = [ ObjectColumn(name='isotope',
                    label='Isotope',
                    #tooltip='Isotope name in natrual (LLAAAM) form.',
#                    width=0.20,
                    ),
                ObjectColumn(name='mass_weight',
                    label='Mass Weight', 
                    #tooltip='Mass weight of the corresponding isotope.',
#                    width=0.20, 
                    ),
                ],
    deletable   = True,   
    sort_model  = True,   
    auto_size   = False,
    orientation = 'vertical',
    filters     = [ UFilter,
github NMGRL / pychron / pychron / database / tasks / connection_preferences.py View on Github external
def get_fav_group(self, edit_view=None):
        cols = self.get_columns()
        editor = TableEditor(columns=cols,
                             selected='_selected',
                             sortable=False)
        if edit_view:
            editor.edit_view = edit_view

        fav_grp = VGroup(UItem('_fav_items',
                               width=100,
                               editor=editor),
                         HGroup(self.get_buttons(),
                                Spring(width=10, springy=False),
                                Label('Status:'),
                                CustomLabel('_connected_label',
                                            label='Status',
                                            weight='bold',
                                            color_name='_connected_color'),
                                spring,
github NMGRL / pychron / pychron / extraction_line / view_controller.py View on Github external
def _table_editor_factory(self):
        '''
        '''
        col = [ObjectColumn(name='name'),
             ObjectColumn(name='key')]
        return TableEditor(columns=col,
                           auto_size=False,
                           orientation='vertical',
                           show_toolbar=True,
                           row_factory=self.row_factory,
                           deletable=True,
                           edit_view=View(
                                            Group(
                                                HGroup('name', 'key'),
                                                Item('x', editor=RangeEditor(low_name='xmin',
                                                                            high_name='xmax',
                                                                            mode='slider')),
                                                Item('y', editor=RangeEditor(low_name='xmin',
                                                                            high_name='xmax',
                                                                            mode='slider')),
                                                Item('z', editor=RangeEditor(low_name='xmin',
                                                                            high_name='xmax',
github enthought / traitsui / examples / demo / Advanced / List_editors_demo.py View on Github external
# Sample data:
people = [
   Person( name = 'Dave',   age = 39, phone = '555-1212' ),
   Person( name = 'Mike',   age = 28, phone = '555-3526' ),
   Person( name = 'Joe',    age = 34, phone = '555-6943' ),
   Person( name = 'Tom',    age = 22, phone = '555-7586' ),
   Person( name = 'Dick',   age = 63, phone = '555-3895' ),
   Person( name = 'Harry',  age = 46, phone = '555-3285' ),
   Person( name = 'Sally',  age = 43, phone = '555-8797' ),
   Person( name = 'Fields', age = 31, phone = '555-3547' )
]

# Table editor definition:
filters      = [ EvalFilterTemplate, MenuFilterTemplate, RuleFilterTemplate ]

table_editor = TableEditor(
    columns     = [ ObjectColumn( name = 'name',  width = 0.4 ),
                    ObjectColumn( name = 'age',   width = 0.2 ),
                    ObjectColumn( name = 'phone', width = 0.4 ) ],
    editable    = True,
    deletable   = True,
    sortable    = True,
    sort_model  = True,
    auto_size   = False,
    filters     = filters,
    search      = RuleTableFilter(),
    row_factory = Person
)

# 'ListTraitTest' class:
class ListTraitTest ( HasStrictTraits ):