[英]TraitsUI CheckListEditor with default selections?
I'm using a CheckListEditor (source , docs ) to present a list of options to users for configuring a simulation. 我正在使用CheckListEditor (源 , docs )向用户显示用于配置模拟的选项列表。 By using the
custom
View options, it displays these selections as checkboxes. 通过使用
custom
视图”选项,它将这些选择显示为复选框。 What I can't figure out is how to set some pre-selected or pre-checked boxes? 我不知道该如何设置一些预选或预选框? IE the default settings for the simulation.
IE的模拟默认设置。
from traits.api import *
from traitsui.api import *
class Test(HasTraits):
foo = List(editor=CheckListEditor(values = ['a','b','c']))
traits_view = View(Item('foo', style='custom'))
Test().configure_traits()
Below is a SS of the output. 下面是输出的SS。 How would I initialize this with say
a
and b
checked? 我将如何用
a
和b
进行初始化?
Thanks. 谢谢。
One way is to specify the default value of the List
. 一种方法是指定
List
的默认值。 That is, change this: 也就是说,更改此:
foo = List(editor=CheckListEditor(values = ['a','b','c']))
to 至
foo = List(editor=CheckListEditor(values = ['a','b','c']), value=['a', 'b'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.