<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-02-27 9:08 GMT+01:00 Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 2/26/2016 5:12 PM, Maxime S wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">
<br>
2016-02-25 17:47 GMT+01:00 Guido van Rossum<br>
<<a href="mailto:guido@python.org" target="_blank">guido@python.org</a><br></span>
<mailto:<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>>>:<span class=""><br>
<br>
    When you're implementing this API on top of tkinter, you'll probably<br>
    find that you'll have to use tkinter's way of sleeping anyways, so the<br>
    implementation of waiting in BaseEventLoop using a selector is not<br>
    useful for this scenario.<br>
<br>
    There are probably some possible refactorings in the asyncio package<br>
    to help you reuse a little more code, but all in all I still think it<br>
    would be very useful to have an asyncio loop integrated with Tkinter.<br>
    (Of course Tkinter does support network I/O, so it would be possible<br>
    to integrate with that, too. Or some hybrid where you somehow figure<br>
    out how to wait using a Selector *or* tkinter events in the same<br>
    loop.)<br>
<br>
<br>
It is actually quite easy to implement an asyncio loop over tkinter once<br>
you realise that tkapp.dooneevent() is very similar to poll(), and<br>
</span></blockquote>
<br>
It took me awhile to understand what you mean by 'tkapp'.  Instances of tkinter.Tk get an undocumented .tk attribute that is an instance of the undocumented and hidden _tkinter class that is called 'tkapp' in printed representations.  In other words, after<br>
<br></blockquote><div><br></div><div>I actually meant an instance of Tk(), which also have dooneevent(). Sorry this wasn't clear.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
import tkinter as tk<br>
root = tk.Tk()<br>
tkapp = <a href="http://root.tk" rel="noreferrer" target="_blank">root.tk</a><br>
<br>
tkapp has a dooneevent method.  I found the tcl doc for it at<br>
<a href="https://www.tcl.tk/man/tcl/TclLib/DoOneEvent.htm" rel="noreferrer" target="_blank">https://www.tcl.tk/man/tcl/TclLib/DoOneEvent.htm</a><br>
Does calling it with DONT_WAIT "TCL_DONT_WAIT - Do not sleep: process only events that are ready at the time of the call." differ from calling root.update?<br><div><div class="h5"><br></div></div></blockquote><div><br></div><div>Good point. The code under update() is essentially this (plus some error cheking):</div><div><br></div><div><div>if (nargs == 1) {</div><div>    flags = TCL_DONT_WAIT;</div><div>} else {</div></div><div>    flags = TCL_IDLE_EVENTS;<br></div><div>}</div><div><br></div><div>while (Tcl_DoOneEvent(flags) != 0) {}</div><div><br></div><div>So, it is probably much more efficent to call update() than to do the same loop in python as I did, and it avoid messing around with _tkinter undocumented flags. </div></div></div></div>