0

I need to build a dynamic list of Enums, where each element of the list should contain the same reference Enum. Then the user can choose the value from the Enum. Here is my code:

class EnumListContainer(HasTraits):
    values = ['a', 'b', 'c']
    enum_list = List(Enum(values))

elc = EnumListContainer()
elc.configure_traits()

It runs fine and shows what I need except that I do not know the content of values in advance. How should I update that simple code to be able to pass a list at run time? I have tried a few things but I don't seem to be getting anywhere.

Thanks A.

malekcellier
  • 177
  • 3
  • 10

1 Answers1

0

It isn't quite clear to me what you are asking, but as far as I can tell, its something like this:

class EnumListContainer(HasTraits):
  values=List(Str)
  enumlist=List(Enum)

  def __init__(self,vals):
    self.values=vals

  def _enumlist_default(self):
    return List(self.values)
aestrivex
  • 5,170
  • 2
  • 27
  • 44