Tabbed groups and how to find out which group is selected

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Tabbed groups and how to find out which group is selected

sylvain roy
Hello,

Here is an example of two groups displayed using a tabbed layout.
The groups are named: group1 and group2.
I was wondering if there was a way to find out which group is selected.
For instance, in the example, the attribute named selected_group would
be updated every time a user select a new group on the interface.

Hope I'm clear.
Regards,
Sylvain

from enthought.traits.api import HasTraits, Str
from enthought.traits.ui.api import View, Item, Group

class MyClass(HasTraits):
   
    a = Str('Hello')
    b = Str('Bonjour')
    selected_group = Str
   
    group1 = Group(Item('a'), dock='tab')
    group2 = Group(Item('b'), dock='tab')
   
    traits_view = View(Group(group1,
                       group2,
                       layout='tabbed'))


if __name__ == "__main__":
    my_object = MyClass()
    my_object.configure_traits()
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tabbed groups and how to find out which group is selected

Stephan Gerhard
Hi,
I would like to use this functionality as well. Unforunately, nobody has
answered to this question.

Is it possible at all?

Regards,
Stephan

Am Dienstag, den 10.08.2010, 20:34 +0200 schrieb Sylvain Roy:

> Hello,
>
> Here is an example of two groups displayed using a tabbed layout.
> The groups are named: group1 and group2.
> I was wondering if there was a way to find out which group is selected.
> For instance, in the example, the attribute named selected_group would
> be updated every time a user select a new group on the interface.
>
> Hope I'm clear.
> Regards,
> Sylvain
>
> from enthought.traits.api import HasTraits, Str
> from enthought.traits.ui.api import View, Item, Group
>
> class MyClass(HasTraits):
>    
>     a = Str('Hello')
>     b = Str('Bonjour')
>     selected_group = Str
>    
>     group1 = Group(Item('a'), dock='tab')
>     group2 = Group(Item('b'), dock='tab')
>    
>     traits_view = View(Group(group1,
>                        group2,
>                        layout='tabbed'))
>
>
> if __name__ == "__main__":
>     my_object = MyClass()
>     my_object.configure_traits()
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tabbed groups and how to find out which group is selected

fred-2
Le 15/12/2010 11:32, Stephan Gerhard a écrit :
> Hi,
> I would like to use this functionality as well. Unforunately, nobody has
> answered to this question.
>
> Is it possible at all?
I'm interested in too...

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tabbed groups and how to find out which group is selected

bryce hendrix-2
In reply to this post by Stephan Gerhard
On Wed, Dec 15, 2010 at 4:32 AM, Stephan Gerhard <[hidden email]> wrote:
Hi,
I would like to use this functionality as well. Unforunately, nobody has
answered to this question.

Is it possible at all?



Stephan,

If you use the ListEditor, there is a 'selected' argument which maps to your attribute. Something like this:

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

class StrWrapper(HasTraits):
    value = Str
    traits_value = View(Item('value'))

class MyClass(HasTraits):
    ways_to_say_hello = List(StrWrapper)
    selected = Instance(StrWrapper)

    traits_view = View(Item('ways_to_say_hello',
                            style='custom',
                            editor=ListEditor(use_notebook=True,
                                              dock_style='tab',
                                              ui_kind='panel',
                                              selected='selected',
                                              page_name='.value')))

    def _ways_to_say_hello_default(self):
        return [StrWrapper(value='hello'),
                StrWrapper(value='bonjour'),
                StrWrapper(value='guten tag')]

    def _selected_changed(self):
        print "new selected tab:", self.selected

MyClass().configure_traits()
 
Regards,
Stephan

Am Dienstag, den 10.08.2010, 20:34 +0200 schrieb Sylvain Roy:
> Hello,
>
> Here is an example of two groups displayed using a tabbed layout.
> The groups are named: group1 and group2.
> I was wondering if there was a way to find out which group is selected.
> For instance, in the example, the attribute named selected_group would
> be updated every time a user select a new group on the interface.
>
> Hope I'm clear.
> Regards,
> Sylvain
>
> from enthought.traits.api import HasTraits, Str
> from enthought.traits.ui.api import View, Item, Group
>
> class MyClass(HasTraits):
>
>     a = Str('Hello')
>     b = Str('Bonjour')
>     selected_group = Str
>
>     group1 = Group(Item('a'), dock='tab')
>     group2 = Group(Item('b'), dock='tab')
>
>     traits_view = View(Group(group1,
>                        group2,
>                        layout='tabbed'))
>
>
> if __name__ == "__main__":
>     my_object = MyClass()
>     my_object.configure_traits()
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tabbed groups and how to find out which group is selected

fred-2
Le 15/12/2010 21:21, bryce hendrix a écrit :

> On Wed, Dec 15, 2010 at 4:32 AM, Stephan Gerhard <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>     I would like to use this functionality as well. Unforunately, nobody has
>     answered to this question.
>
>     Is it possible at all?
>
>
>
> Stephan,
>
> If you use the ListEditor, there is a 'selected' argument which maps to
> your attribute. Something like this:
I was thinking without using ListEditor (I already use this trick in my
code) but only tabs (with different traits in each of them, ie not a
part of a list)...

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tabbed groups and how to find out which group is selected

Brennan Williams
On 16/12/2010 9:48 a.m., Fred wrote:

> Le 15/12/2010 21:21, bryce hendrix a écrit :
>> On Wed, Dec 15, 2010 at 4:32 AM, Stephan Gerhard<[hidden email]
>> <mailto:[hidden email]>>  wrote:
>>
>>      Hi,
>>      I would like to use this functionality as well. Unforunately, nobody has
>>      answered to this question.
>>
>>      Is it possible at all?
>>
>>
>>
>> Stephan,
>>
>> If you use the ListEditor, there is a 'selected' argument which maps to
>> your attribute. Something like this:
> I was thinking without using ListEditor (I already use this trick in my
> code) but only tabs (with different traits in each of them, ie not a
> part of a list)...
>
+1 from me.

I use a TreeEditor with the view for the selected tree item often having
a few (or more) tabs in it. One of the things I'd like to be able to do
is to go back to a previously viewed tree item and have the last viewed
tab as the displayed/selected tab. At the moment the view will revert to
the default tab.
Actually there is a "selected=" option so maybe if I have a
lastviewedtab=Str('') attribute for each viewable item/class and used
selected=lastviewedtab that might work?

Brennan


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Tabbed groups and how to find out which group is selected

fred-2
Le 15/12/2010 22:15, Brennan Williams a écrit :

> On 16/12/2010 9:48 a.m., Fred wrote:
>> Le 15/12/2010 21:21, bryce hendrix a écrit :
>>> On Wed, Dec 15, 2010 at 4:32 AM, Stephan Gerhard<[hidden email]
>>> <mailto:[hidden email]>>   wrote:
>>>
>>>       Hi,
>>>       I would like to use this functionality as well. Unforunately, nobody has
>>>       answered to this question.
>>>
>>>       Is it possible at all?
>>>
>>>
>>>
>>> Stephan,
>>>
>>> If you use the ListEditor, there is a 'selected' argument which maps to
>>> your attribute. Something like this:
>> I was thinking without using ListEditor (I already use this trick in my
>> code) but only tabs (with different traits in each of them, ie not a
>> part of a list)...
>>
> +1 from me.
I agree, IIRC, Brennan ;-)

--
Fred
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev