and the simpler examples aheadwidget after_idle(function*argsthis tool schedules the function to be called once when there are no more pending events to process that isfunction becomes an idle handlerwhich is invoked when the gui isn' busy doing anything else widget after_cancel(idthis tool cancels pending after callback event before it occursid is the return value of an after event scheduling call widget update(this tool forces tkinter to process all pending events in the event queueincluding geometry resizing and widget updates and redraws you can call this periodically from long-running callback handler to refresh the screen and perform any updates to it that your handler has already requested if you don'tyour updates may not appear on-screen until your callback handler exits in factyour display may hang completely during long-running handlers if not manually updated (and handlers are not run in threadsas described in the next section)the window won' even redraw itself until the handler returns if covered and uncovered by another for instanceprograms that animate by repeatedly moving an object and pausing must call for an update before the end of the animation or only the final object position will appear on-screenworsethe gui will be completely inactive until the animation callback returns (see the simple animation examples later in this as well as pydraw in widget update_idletasks(this tool processes any pending idle events this may sometimes be safer than afterwhich has the potential to set up race (loopingconditions in some scenarios tk widgets use idle events to display themselves _tkinter createfilehandler(filemaskfunctionthis tool schedules the function to be called when file' status changes the function may be invoked when the file has data for readingis available for writingor triggers an exception the file argument is python file or socket object (technicallyanything with fileno(methodor an integer file descriptormask is tkinter readable or tkinter writable to specify the modeand the callback function takes two arguments--the file ready to converse and mask file handlers are often used to process pipes or socketssince normal input/output requests can block the caller because this call is not available on windowsit won' be used in this book since it' currently unix-only alternativeportable guis may be better off using after timer loops to poll for data and spawning threads to read data and place it on queues if needed--see for more details threads are much more general solution to nonblocking data transfers time toolsthreadsand animation