Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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
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 =============================================
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
# 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:
#-------------------------------------------------------------------------
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
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({})
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: (
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')),
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