Async File I/O

Randall Hopper aa8vb at
Sat Feb 19 01:22:10 CET 2000

Randall Hopper <aa8vb at> wrote:
 |Is there a way to perform asynchronous file I/O in Python which is
 |compatible with Tkinter?
 |I believe Tk's fileevent might be it, but I don't see any wrapper in 
 |the Tkinter module.  Anyone have a code snippet they could share?

Never mind.  I found the code bite I needed buried in Dejanews.  The answer
for Tkinter (on UNIX) is "createfilehandler".

UNIX is sufficient for my needs.  But what do Tkinter folks do with this
situation on MSWindows?  Sleep and poll?  Or is there another API that's

Randall Hopper
aa8vb at

#!/usr/bin/env python
#  From: Olaf Delgado <delgado at Mathematik.Uni-Bielefeld.DE>
#  Date: 03 May 1999 00:00:00 GMT
#  Subject: Re: Tkinter and fileevent

import sys
import Tkinter
import tkMessageBox

root = Tkinter.Tk()

def stdin_handler(file, mask):
    if not tkMessageBox.askokcancel("Go on?", file.readline()):
        root.destroy(), mask, stdin_handler), Tkinter.READABLE, stdin_handler)


More information about the Python-list mailing list