mirror of https://github.com/python/cpython
Issue #989712: Support using Tk without a mainloop.
This commit is contained in:
parent
30c825c751
commit
a2251aadaa
|
@ -38,6 +38,21 @@ else:
|
||||||
return s
|
return s
|
||||||
warnings.formatwarning = idle_formatwarning_subproc
|
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
|
# Thread shared globals: Establish a queue between a subthread (which handles
|
||||||
# the socket) and the main thread (which runs user code), plus global
|
# the socket) and the main thread (which runs user code), plus global
|
||||||
# completion, exit and interruptable (the main thread) flags:
|
# completion, exit and interruptable (the main thread) flags:
|
||||||
|
@ -93,6 +108,7 @@ def main(del_exitfunc=False):
|
||||||
try:
|
try:
|
||||||
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
|
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
|
handle_tk_events()
|
||||||
continue
|
continue
|
||||||
method, args, kwargs = request
|
method, args, kwargs = request
|
||||||
ret = method(*args, **kwargs)
|
ret = method(*args, **kwargs)
|
||||||
|
|
|
@ -24,6 +24,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #989712: Support using Tk without a mainloop.
|
||||||
|
|
||||||
- Issue #5219: Prevent event handler cascade in IDLE.
|
- Issue #5219: Prevent event handler cascade in IDLE.
|
||||||
|
|
||||||
- Issue #3835: Refuse to use unthreaded Tcl in threaded Python.
|
- Issue #3835: Refuse to use unthreaded Tcl in threaded Python.
|
||||||
|
|
Loading…
Reference in New Issue