enthought / enthought/traitsui
OKButton cannot be renamed
- Dominant language
- Python
- Stars
- 306
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
The [OKButton](https://docs.enthought.com/traitsui/api/traitsui.menu.html?highlight=okbutton#traitsui.menu.OKButton) has special behaviour that is not replicable by defining another [Action](https://docs.enthought.com/traitsui/traitsui_user_manual/handler.html#actions) - when it is clicked, the `close` method is fired with `is_ok=True`. It would be useful to make it possible to rename this button (for example, to localise to another language) but keep the special window closing behaviour. This also applies to other built in Actions.
Example:
```
from traits.api import HasTraits, Str, Instance
from traitsui.api import View, Item, ModelView
from traitsui.menu import OKButton, CancelButton
class Demo(HasTraits):
name = Str()
class DemoView(ModelView):
model = Instance(Demo)
def close(self, info, is_ok):
if is_ok:
print('Closed using OKButton') # some behaviour
else:
print('Closed some other way') # some other behaviour
return True
def default_traits_view(self):
return View(Item('model.name'), buttons = [OKButton, CancelButton])
demoview = DemoView(model=Demo())
demoview.configure_traits()
```
gives

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.