Reputation: 1888
I find myself waiting for the GUI of my Traits/UI application to update, with each backspace and/or digit entry in a particular field. How can I get the Traits/UI notification system to wait until I press RETURN before it sends out change notifications?
Upvotes: 1
Views: 55
Reputation: 1743
You want to use the auto_set
and enter_set
attributes of a TextEditor
. auto_set=False
stops updating the trait on every keystroke, and enter_set=True
causes it to update on Enter. See here for docs.
For example: from traits.api import HasTraits, Str from traitsui.api import View, TextEditor, Group, Item
class Foo(HasTraits):
my_str = Str()
traits_view = View(
Item('my_str',
style='custom',
editor=TextEditor(
auto_set=False,
enter_set=True,
),
),
Item('my_str',
style='readonly'
),
)
if __name__ == '__main__':
f = Foo()
f.configure_traits()
Upvotes: 1