Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54124 > unrolled thread
| Started by | petmertens@gmail.com |
|---|---|
| First post | 2013-09-13 10:35 -0700 |
| Last post | 2013-10-03 11:09 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
Get the selected tab in a enthought traits application petmertens@gmail.com - 2013-09-13 10:35 -0700
Re: Get the selected tab in a enthought traits application shi <shi@somewhere.be> - 2013-09-15 09:56 +0200
Re: Get the selected tab in a enthought traits application petmertens@gmail.com - 2013-10-03 11:09 -0700
| From | petmertens@gmail.com |
|---|---|
| Date | 2013-09-13 10:35 -0700 |
| Subject | Get the selected tab in a enthought traits application |
| Message-ID | <7aba29d3-dc9e-4a9c-82d5-edfab19d767c@googlegroups.com> |
Hi, I have a traits application with a tabbed group: Group( Group(label="a", dock='tab'), Group(label="b", dock='tab'), layout='tabbed') Beneath the tabbed group, there is button which should perform some action depending on the selected tab. So I would like to know which of both tabs, 'a' or 'b', is selected (i.e. active). Any ideas? Thanks
[toc] | [next] | [standalone]
| From | shi <shi@somewhere.be> |
|---|---|
| Date | 2013-09-15 09:56 +0200 |
| Message-ID | <l13p76$ms8$1@speranza.aioe.org> |
| In reply to | #54124 |
> Any ideas? I think you will have more chance for an answer in a more specialized list, e.g. the enthought-dev mailing list, which is also accessible via gmane: http:// dir.gmane.org / gmane.comp.python.enthought.devel Stefaan.
[toc] | [prev] | [next] | [standalone]
| From | petmertens@gmail.com |
|---|---|
| Date | 2013-10-03 11:09 -0700 |
| Message-ID | <6db8a695-d577-43a1-99f6-cf82793aa142@googlegroups.com> |
| In reply to | #54124 |
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()
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web