Get the selected tab in a enthought traits application
petmertens at gmail.com
petmertens at gmail.com
Thu Oct 3 14:09:16 EDT 2013
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()
More information about the Python-list
mailing list