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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com