On 2/27/2016 4:42 AM, Maxime S wrote:
2016-02-27 9:08 GMT+01:00 Terry Reedy
mailto:tjreedy@udel.edu>:
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
I actually meant an instance of Tk(), which also have dooneevent(). Sorry this wasn't clear.
I was fooled because in 3.x dooneevent does not show up on the root completion list. 3.x Tk must have a __getattr__ that pulls attributes from its tk (tkapp) attribute. # 3.5.1
import tkinter as tk root = tk.Tk() 'dooneevent' in tk.Tk.__dict__ False 'dooneevent' in root.__dict__ False root.dooneevent
For 2.x, dooneevent does appear as a completion, though I don't know how or why, as I get the same False and False as above. (I will have to see if the completion code changed, or if something else changed to change its meaning.)
import tkinter as tk root = tk.Tk() tkapp = root.tk http://root.tk
tkapp has a dooneevent method. I found the tcl doc for it at https://www.tcl.tk/man/tcl/TclLib/DoOneEvent.htm 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?
Good point. The code under update() is essentially this (plus some error cheking):
if (nargs == 1) { flags = TCL_DONT_WAIT; } else { flags = TCL_IDLE_EVENTS; }
while (Tcl_DoOneEvent(flags) != 0) {}
Thanks for checking this.
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.
-- Terry Jan Reedy