[Python-checkins] cpython: Issue #27620: Make htest box respond to <Return> and <Escape>.

terry.reedy python-checkins at python.org
Wed Jul 27 22:17:28 EDT 2016


https://hg.python.org/cpython/rev/e4a2d78aa6cc
changeset: 102469:e4a2d78aa6cc
user: Terry Jan Reedy <tjreedy at udel.edu>
date: Wed Jul 27 22:17:05 2016 -0400
summary:
 Issue #27620: Make htest box respond to <Return> and <Escape>.
files:
 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
--- a/Lib/idlelib/idle_test/htest.py
+++ b/Lib/idlelib/idle_test/htest.py
@@ -380,7 +380,7 @@
 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 @@
 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__':
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /