我想在表的每一行末尾添加一个按钮。在
关闭窗口时,以下代码会导致PyDeadObjectError:
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()
有人已经试过这么做了吗?我怎样才能消除这个错误?是否可以在不单击相应单元格的情况下显示按钮?在
我不确定问题出在哪里,但也许有一个解决办法。使用一个按钮,然后使用所选行,而不是让一列按钮充满按钮。在
否则,也许checkbox_列示例是一个很好的起点。在
相关问题 更多 >
编程相关推荐