Tkinter and fileevent

Olaf Delgado delgado at Mathematik.Uni-Bielefeld.DE
Mon May 3 04:52:33 EDT 1999


On 2 May 1999, Lloyd Zusman wrote:

> Does Tkinter provide an interface to Tcl's `fileevent' mechanism?  I
> couldn't find this anywhere in the Tkinter documentation or examples.
> 
> If `fileevent' is indeed accessible via Tkinter, could someone point me
> to some docs or examples where this is used?

I had to ask a similar question some weeks ago. It would be nice to have
some more documentations on features like that to help newbies like us.
Here's a small working example that uses filehandler:

#---snip---
import sys
import Tkinter
import tkMessageBox

root = Tkinter.Tk()

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

root.tk.createfilehandler(sys.stdin, Tkinter.READABLE, stdin_handler)

root.mainloop()
#---snap---

Olaf






More information about the Python-list mailing list