diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2016-07-28 02:17:05 (GMT) |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2016-07-28 02:17:05 (GMT) |
commit | 2553b1b0578f1986d637afa77d4c4656769a172b (patch) | |
tree | 7890556c17b300de3f899bfca894d95443905b1c /Lib/idlelib | |
parent | 6b37dfce5bafe96472f8936a7a44fad0abae9e98 (diff) | |
download | cpython-2553b1b0578f1986d637afa77d4c4656769a172b.zip cpython-2553b1b0578f1986d637afa77d4c4656769a172b.tar.gz cpython-2553b1b0578f1986d637afa77d4c4656769a172b.tar.bz2 |
Issue #27620: Make htest box respond to <Return> and <Escape>.
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/idle_test/htest.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py index c59ed8c..6f676ae 100644 --- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -380,7 +380,7 @@ def run(*tests): callable_object = None test_kwds = None - def next(): + def next_test(): nonlocal test_name, callable_object, test_kwds if len(test_list) == 1: @@ -395,20 +395,26 @@ def run(*tests): text.insert("1.0",test_spec['msg']) text.configure(state='disabled') # preserve read-only property - def run_test(): + def run_test(_=None): widget = callable_object(**test_kwds) try: print(widget.result) except AttributeError: pass - button = tk.Button(root, textvariable=test_name, command=run_test) + def close(_=None): + root.destroy() + + button = tk.Button(root, textvariable=test_name, + default='active', command=run_test) + next_button = tk.Button(root, text="Next", command=next_test) button.pack() - next_button = tk.Button(root, text="Next", command=next) next_button.pack() + next_button.focus_set() + root.bind('<Key-Return>', run_test) + root.bind('<Key-Escape>', close) - next() - + next_test() root.mainloop() if __name__ == '__main__': |