enthought / enthought/traitsui

current selected tab issue

Open
#1,991 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
306
Forks
99
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.