summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2012-03-14 01:36:13 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2012-03-14 01:36:13 (GMT)
commita2251aadaa6de54eaf9663451afd16806a0712f3 (patch)
treef036901fec13e5bc6c0fa350640fb74d8b66135d
parent30c825c7510ccb9a9999e95c6013a5ec60938d79 (diff)
downloadcpython-a2251aadaa6de54eaf9663451afd16806a0712f3.zip
cpython-a2251aadaa6de54eaf9663451afd16806a0712f3.tar.gz
cpython-a2251aadaa6de54eaf9663451afd16806a0712f3.tar.bz2
Issue #989712: Support using Tk without a mainloop.
-rw-r--r--Lib/idlelib/run.py16
-rw-r--r--Misc/NEWS2
2 files changed, 18 insertions, 0 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 25338ff..962c6c0 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -38,6 +38,21 @@ else:
return s
warnings.formatwarning = idle_formatwarning_subproc
+
+def handle_tk_events():
+ """Process any tk events that are ready to be dispatched if tkinter
+ has been imported, a tcl interpreter has been created and tk has been
+ loaded."""
+ tkinter = sys.modules.get('tkinter')
+ if tkinter and tkinter._default_root:
+ # tkinter has been imported, an Tcl interpreter was created and
+ # tk has been loaded.
+ root = tkinter._default_root
+ while root.tk.dooneevent(tkinter._tkinter.DONT_WAIT):
+ # Process pending events.
+ pass
+
+
# Thread shared globals: Establish a queue between a subthread (which handles
# the socket) and the main thread (which runs user code), plus global
# completion, exit and interruptable (the main thread) flags:
@@ -93,6 +108,7 @@ def main(del_exitfunc=False):
try:
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
except queue.Empty:
+ handle_tk_events()
continue
method, args, kwargs = request
ret = method(*args, **kwargs)
diff --git a/Misc/NEWS b/Misc/NEWS
index aee1ad8..9b4d2c2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,8 @@ Core and Builtins
Library
-------
+- Issue #989712: Support using Tk without a mainloop.
+
- Issue #5219: Prevent event handler cascade in IDLE.
- Issue #3835: Refuse to use unthreaded Tcl in threaded Python.