Looking at the code, it is fairly hard-coded into the View implementation, but you can override it by binding the escape key to a "do nothing" handler using TraitsUI keybindings:
from traits.api import HasTraits, Range
from traitsui.api import View, Item
from traitsui.key_bindings import KeyBinding, KeyBindings
bindings = KeyBindings(
KeyBinding(
binding1='Esc',
description='Stop Escape from closing window',
method_name='do_nothing',
)
)
class StopEscapeClosingExample(HasTraits):
value = Range(0, 100)
def do_nothing(self, ui_info):
pass
traits_view = View(
Item('value', enabled_when='not _running'),
key_bindings=bindings,
)
if __name__ == '__main__':
example = StopEscapeClosingExample()
example.configure_traits()
This is not the most elegant solution, but it appears to work.
Hope this helps,
-- Corran