Martin v. Löwis wrote: >Michiel Jan Laurens de Hoon wrote: > > >>But there is another solution with threads: Can we let Tkinter run in a >>separate thread instead? >> >> > >Yes, you can. Actually, Tkinter *always* runs in a separate thread >(separate from all other threads). > > Are you sure? If Tkinter is running in a separate thread, then why does it need PyOS_InputHook? Maybe I'm misunderstanding the code in _tkinter.c, but it appears that the call to Tcl_DoOneEvent and the main interpreter (the one that reads the user commands from stdin) are in the same thread. Anyway, if we can run Tkinter's event loop in a thread separate from the main interpreter, then we can avoid all interference with other event loops, and also improve Tkinter's behavior itself: 1) Since this event loop doesn't need to check stdin any more, we can avoid the busy-wait-sleep loop by calling Tcl_DoOneEvent without the TCL_DONT_WAIT flag, and hence get better performance. 2) With the event loop in a separate thread, we can use Tkinter from IDLE also. --Michiel. -- Michiel de Hoon Center for Computational Biology and Bioinformatics Columbia University 1150 St Nicholas Avenue New York, NY 10032
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4