Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current selected tab issue #1991

Open
fred4ets opened this issue Mar 11, 2023 · 0 comments
Open

current selected tab issue #1991

fred4ets opened this issue Mar 11, 2023 · 0 comments

Comments

@fred4ets
Copy link

In the following CME, pressing on the Show tabs button, select one tab (say #2), close dialog and then pressing Show tabs buttons
shows that the current tab is the first, not the one previously selected.

Any idea?

Regards

from traits.api import *
from traitsui.api import *

class Tab(HasTraits):

name = String

class Tabs(HasTraits):

current_tab = Instance(Tab)
tabs_list = List(Instance(Tab))

view = View(Group(UCustom('tabs_list',
                          # springy=True,
                          # width=300,  # width value is arbitrary but required
                          editor=ListEditor(use_notebook=True,
                                            dock_style='tab',
                                            selected='current_tab',
                                            page_name='.name'))),
            kind='subpanel',
            buttons=['Undo', 'OK', 'Cancel', 'Help'])
view.close_result = False

def _current_tab_default(self):
    return (self.tabs_list[0])

def _tabs_list_default(self):

    tabs_list = []
    for i in range(3):
        tab = Tab(name='tab #%d' % (i+1))
        tabs_list.append(tab)
    return (tabs_list)

class Foo(HasTraits):

button = Button('Show tabs')

tabs = Instance(Tabs)

view = View(Group(UItem('button')),
            buttons=['Undo', 'OK', 'Cancel', 'Help'])

def _tabs_default(self):
    return (Tabs())

def _button_fired(self):
    print('current_tab:', self.tabs.current_tab.name)
    self.tabs.edit_traits()

foo = Foo()
if name == 'main':
foo.configure_traits()

Debian x86_64, Python 3.9.2, ETS source from git, PyQt 5.15.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant