Here's the answer:

from enthought.traits.api import HasTraits, Str, List, Button, Any
from enthought.traits.ui.api import View, Item
from enthought.traits.ui.api import ListEditor

class A(HasTraits):
   StringA = Str

   view = View(Item('StringA'))

class B(HasTraits):
   StringB = Str

   view = View(Item('StringB'))

class C(HasTraits):
   MyList = List(HasTraits)
   MyButton = Button(label="Test")
   SelectedTab = Any

   def _MyButton_fired(self):
      if self.SelectedTab == self.MyList[0]:
         print self.MyList[0].StringA
      if self.SelectedTab == self.MyList[1]:
         print self.MyList[1].StringB

   view = View(Item('MyList', style='custom', show_label=False, 
                  editor=ListEditor(use_notebook=True, deletable=False, 
dock_style='tab', selected='SelectedTab')),
               Item('MyButton', show_label=False))

a = A()
b = B()
c = C()
c.MyList = [a, b]

c.configure_traits()
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to