How to use the traitsui.table_column.ObjectColumn 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 / traitsui / wx / table_editor.py View on Github external
def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """

        factory = self.factory
        self.filter = factory.filter
        self.auto_add = (
            factory.auto_add and (
                factory.row_factory is not None))

        columns = factory.columns[:]
        if (len(columns) == 0) and (len(self.value) > 0):
            columns = [ObjectColumn(name=name)
                       for name in self.value[0].editable_traits()]
        self.columns = columns

        self.model = model = TableModel(
            editor=self,
            reverse=factory.reverse)
        model.on_trait_change(self._model_sorted, 'sorted', dispatch='ui')
        mode = factory.selection_mode
        row_mode = mode in ('row', 'rows')
        selected = None
        items = model.get_filtered_items()
        if factory.editable and (len(items) > 0):
            selected = items[0]
        if (factory.edit_view == ' ') or (not row_mode):
            self.control = panel = TraitsUIPanel(parent, -1)
            sizer = wx.BoxSizer(wx.VERTICAL)
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 / pipeline / editors / flux_visualization_editor.py View on Github external
def traits_view(self):
        cols = [CheckboxColumn(name='use'),
                ObjectColumn(name='hole_id'),
                ObjectColumn(name='identifier'),
                ObjectColumn(name='mean_j', format='%0.5e'),
                ObjectColumn(name='mean_jerr', format='%0.5e'),
                ObjectColumn(name='j', label='Pred. J', format='%0.5e'),
                ObjectColumn(name='mean_dev', label='Mean Dev.', format='%0.2f')
                ]
        g3d = VGroup(UItem('rotation'),
                     HGroup(UItem('graph', style='custom'),
                            UItem('monitor_positions',
                                  width=-400,
                                  editor=TableEditor(columns=cols, sortable=False))))

        rings = VGroup(HGroup(UItem('ring_graph', style='custom'),
                              UItem('deviation_graph', style='custom'),
                              UItem('spoke_graph', style='custom')))
        return View(Tabbed(rings, g3d))
# ============= EOF =============================================
github NMGRL / pychron / pychron / core / ui / qt / keybinding_editor.py View on Github external
def traits_view(self):
        cols = [ObjectColumn(name='binding', editor=KeyBindingEditor()),
                ObjectColumn(name='description', editable=False, width=400)]
        v = View(UItem('bindings', editor=TableEditor(columns=cols)),
                 width=500,
                 height=600,
                 title='Edit Key Bindings',
                 kind='livemodal',
                 buttons=['OK','Cancel'],
                 resizable=True)
        return v
github enthought / traitsui / traitsui / table_filter.py View on Github external
#  Returns the value of the column for a specified object:
    #-------------------------------------------------------------------------

    def get_value(self, object):
        """ Returns the traits editor of the column for a specified object.
        """
        if object.and_or == 'or':
            return 'or'
        return ''

#-------------------------------------------------------------------------
#  'GenericTableFilterRuleNameColumn' class:
#-------------------------------------------------------------------------


class GenericTableFilterRuleNameColumn(ObjectColumn):
    """ Table column for the name of an object trait.
    """

    #-------------------------------------------------------------------------
    #  Returns the traits editor of the column for a specified object:
    #-------------------------------------------------------------------------

    def get_editor(self, object):
        """ Returns the traits editor of the column for a specified object.
        """
        return object.name_editor

#-------------------------------------------------------------------------
#  'GenericTableFilterRuleValueColumn' class:
#-------------------------------------------------------------------------
github NMGRL / pychron / pychron / pipeline / nodes / email_node.py View on Github external
def traits_view(self):
        cols = [CheckboxColumn(name='enabled'),
                ObjectColumn(name='name'),
                ObjectColumn(name='email', label='Address')]

        v = okcancel_view(UItem('addresses',
                                editor=TableEditor(columns=cols)),
                          title='Configure Email')
        return v
github enthought / traitsui / traitsui / table_column.py View on Github external
return False

    def target_name(self, object):
        """ Returns the target object and name for the column.
        """
        object = self.get_object(object)
        name = self.name
        col = name.rfind(".")
        if col < 0:
            return (object, name)

        return (xgetattr(object, name[:col]), name[col + 1 :])


class ExpressionColumn(ObjectColumn):
    """ A column for displaying computed values.
    """

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

    #: The Python expression used to return the value of the column:
    expression = Expression

    #: Is this column editable?
    editable = Constant(False)

    #: The globals dictionary that should be passed to the expression
    #: evaluation:
    globals = Any({})
github enthought / traitsui / examples / demo / Advanced / Table_editor_with_live_search_and_cell_editor.py View on Github external
def get_value(self, object):
        n = len(self.get_raw_value(object))
        if n == 0:
            return ''

        return str(n)


class MatchesColumn2(ObjectColumn):

    def is_editable(self, object):
        return (len(object.matches) > 0)


class FileColumn(ObjectColumn):

    def get_drag_value(self, object):
        return object.full_name

table_editor = TableEditor(
    columns=[
        MatchesColumn1(
            name='matches',
            label='#',
            editable=False,
            width=0.05,
            horizontal_alignment='center'),
        MatchesColumn2(
            name='matches',
            width=0.35,
            format_func=lambda x: (
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')),
github NMGRL / pychron / pychron / processing / tasks / batch_edit / panes.py View on Github external
def _blanks_group(self):
        cols = [
            ObjectColumn(name='name', editable=False),
            ObjectColumn(name='nominal_value',
                         width=75,
                         label='Value'),
            ObjectColumn(name='std_dev',
                         width=75,
                         label='Error'),
            CheckboxColumn(name='use', label='Save')]
        grp = VGroup(UItem('blanks', editor=TableEditor(columns=cols,
                                                        sortable=False)),
                     label='Blanks')
        return grp