I would like to add a Button to the end of every line in a table.
The following code results in an PyDeadObjectError when closing the window:
from traits.api import HasTraits,Str,Int,Button,Instance
from traitsui.api import TableEditor,ObjectColumn,View
class Person(HasTraits):
name=Str
age=Int
Plot_size=Button(label='Plot size')
class Display(HasTraits):
table=List(Instance(Person))
table_editor=TableEditor(columns=[ObjectColumn(name='name'),
ObjectColumn(name='age'),
ObjectColumn(name='Plot_size')],
deletable = True,
sortable = False,
sort_model = False,
show_lines = True,
orientation = 'vertical',
show_column_labels = True)
traits_view=View(Item('table',editor=table_editor),resizable=True)
a=Display()
a.table.append(Person(name='Joe',age=21))
a.table.append(Person(name='John',age=27))
a.table.append(Person(name='Jenny',age=23))
a.configure_traits()
Has someone already tried to do the same? How can I get rid of this error? Is it possible to display the Button even without clicking on the corresponding cell?