<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 2, 2018 at 8:21 PM, Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 5/2/2018 4:38 PM, Ivan Pozdeev via Python-Dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The bottom line is: Tkinter is currently broken<br>
</blockquote>
<br></span>
This is way over-stated.  Many modules have bugs, somethings in features more central to their main purpose.</blockquote><div><br></div><div>I'll suggest a re-statement:</div><div><br></div><div>tkinter is not thread safe, and yet it is documented as being thread safe (or at least not documented as NOT being thread safe)</div><div><br></div><div>This is either a bug(s) in the implementation or the docs.</div><div><br></div><div>So what are the solutions?</div><div><br></div><div>1) fix the docs -- unless tkInter is made thread safe really soon, and fixes are back-ported, this seems like a no brainer -- at least temporarily.</div><div><br></div><div>2) fix the issues that make tkInter not thread safe -- apparently there is a thread safe tcl/tk, so it should be possible, though I have to say I'm really surprised that that's the case for an old C code base -- but great!</div><div><br></div><div>The problem here is that we'll need qualified people to submit and review the code, and it really should get some extensive testing -- that's a lot of work.</div><div><br></div><div>And it's going to take time, so see (1) above.</div><div><br></div><div>Another issue:</div><div><br></div><div>Many GUI toolkits are not thread safe (I have personal experience with wxPython), so it's not so bad to simply say "don't do that" for tkInter -- that is, don't make tkInter calls from more than one thread.</div><div><br></div><div>However, wxPython (for example) makes this not-too-bad for multi-threaded programs by providing thread-safe ways to put events on the event queue -- whether with wx.PostEvent, or the utilities wx.CallAfter() and wx.CallLater(). This makes it pretty easy to keep the GUI in one thread while taking advantage of threads for long running tasks, etc.</div><div><br></div><div>IIUC, tkinter does not have such an easy way to interact with the GUI from another thread -- so maybe adding that would be a good first step.</div><div><br></div><div>I neither use tkinter, nor have the expertise to contribute this -- but clearly Ivan does -- and maybe others would want to help.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>