I'm using a CheckListEditor (source, docs) to present a list of options to users for configuring a simulation. By using the custom
View options, it displays these selections as checkboxes. What I can't figure out is how to set some pre-selected or pre-checked boxes? IE the default settings for the simulation.
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. How would I initialize this with say a
and b
checked?
Thanks.
One way is to specify the default value of the 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'])